Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert text at current cursor in Forms

Status
Not open for further replies.

lewisp

Programmer
Aug 5, 2001
1,238
GB
Is it possible in forms 4.5 and/or 6i to programatically insert text into a text item at the current cursor position?

I want to allow a user to move the text cursor to any point in a string of text contained in a text item and call a pick-list. The user can then select an item from the list and copy his choice into the text item at the point the cursor is currently sitting.
 
The only way I have found to do this is to :
1) Ensure the text item required has the property 'Keep_Cursor_Position' set to Yes.
2) Add another text item to the form and return the value from the LOV to it.
3) Use code like the following to copy and paste the value into the text string required.

IF Show_LOV('lov_name') THEN
go_item('block_name.lov_value');
select_all;
copy_region;
go_item('block_name.text_field');
paste_region;
END IF;

Hope this helps.
 
Thanks for your advice TheLexx!

Amazingly, the very same day I get an answer from Oracle as well. Their solution is quite neat. p_value is the text you want to paste into the middle of your text item:

PROCEDURE p_paste (p_value IN VARCHAR2) IS
l_text VARCHAR2(1000) := :block.text_item;
BEGIN
Go_Item('BLOCK.TEXT_ITEM');
Clear_Eol;
:block.text_item := :block.text_item ||
p_value ||
Substr(l_text,Length:)block.text_item) + 1);
END;
 
First of all, this small little message has helped me tremendously. thanks lewisp for asking it and then giving your own answer. I'm sure most people would just get the answer and would not be back to present it. Thanks for submitting it.

After investigation, both of these methods work somewhat. One problem with TheLexx's method is that the item "go_item('block_name.lov_value')" must have the visible property set to yes.

This would not work for what I needed so I tried the other method. Which works tremendously--one thing to note--the "keep cursor position" property must be 'yes' for this method too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top