Home » Developer & Programmer » Forms » Cursor manipulation within a text item
Cursor manipulation within a text item [message #167199] Tue, 11 April 2006 16:43 Go to next message
rcd70
Messages: 14
Registered: April 2006
Location: Auckland, New Zealand
Junior Member
Hi

Is there any way of positioning the cursor in a text item or highlighting a part of the text.

I am working on an issue on a form which has a multiline text item. Its difficult for the user to search a string (like name) in the text item as they have to scroll through the entire text item, because at times it can be quite big.

So the solution I came up with is having a SEARCH text item and a checkbox, wherein the user enter the string to be searched in the SEARCH text box and checks the checkbox and the text gets highlighted or the cursor is placed at the beginning of the string in the text item.

Is there any way of highlighting or placing the cursor in the text item at a desired place in the text item.

Any help is very much appreciated.

Thanks
Re: Cursor manipulation within a text item [message #167218 is a reply to message #167199] Tue, 11 April 2006 21:45 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
You will have to use a Java thingy to position the cursor.

I will search for an example and update this post later.

David

Upd: Look at this on metalink which mentions win_api_shell.sendkeys. I searched this forum for 'WIN_API_SHELL' and found this which says to look in d2kwutil, whose documentation says "WIN_API_SHELL - SendKeys - Allows you to simulate User Keystrokes via a macro language". So you use PL/SQL to determine how many cahracters into the field you wish to go, then by using 'win_api_shell.sendkeys' you can 'right arrow' the cursor to the start of the wanted string, then press 'shift' and 'right arrow' to select the text.

[Updated on: Wed, 12 April 2006 00:53]

Report message to a moderator

Re: Cursor manipulation within a text item [message #168128 is a reply to message #167218] Tue, 18 April 2006 23:34 Go to previous messageGo to next message
rcd70
Messages: 14
Registered: April 2006
Location: Auckland, New Zealand
Junior Member
Hi David

Using the win_api_shell.sendkeys, I can position the cursor at the begining or end within the text item. I wanted to place the cursor at the begining of the searched string.
Any suggestions apprecisted.

Thanks

Re: Cursor manipulation within a text item [message #168147 is a reply to message #168128] Wed, 19 April 2006 01:13 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have you tried doing an 'instr' to find out how far 'into the field' you need the curosr and then send that many 'right arrow' instructions in the 'sendkeys' command?

David
Re: Cursor manipulation within a text item [message #168343 is a reply to message #168147] Wed, 19 April 2006 21:09 Go to previous messageGo to next message
rcd70
Messages: 14
Registered: April 2006
Location: Auckland, New Zealand
Junior Member
Hi

THis is the code I am using :

win_api_shell.sendkeys(win,'^{Home}+{Right 1021}',FALSE);

This code highlights the code and places the cursor in the 1021 position in the text item which is correct. However, if the number of characters is more than 1021 the entire text gets highlighted and the cursor is at the end of the text. This is a problem as the text item could be upto 15000 characters.

Is there a limit on the number of positions the cursor can move within a text item.

Please advise.
Re: Cursor manipulation within a text item [message #168381 is a reply to message #168343] Thu, 20 April 2006 02:39 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay ... it looks like there is a 1k buffer (1024 characters).

Please test the following:
Does
win_api_shell.sendkeys(win,'^{Home}+{Right 520}',FALSE);
win_api_shell.sendkeys(win,'+{Right 501}',FALSE);
give the same result (cursor location) as
win_api_shell.sendkeys(win,'^{Home}+{Right 1021}',FALSE);
I do not know the valid values for the second parameter. Do you have a URL?

Anyway, try sending only 1000 movement commands per statement, but use multiple statements so that you get the cursor to where you want it.

David
Re: Cursor manipulation within a text item [message #168510 is a reply to message #168381] Thu, 20 April 2006 16:32 Go to previous messageGo to next message
rcd70
Messages: 14
Registered: April 2006
Location: Auckland, New Zealand
Junior Member
When I use the code mentioned below

win_api_shell.sendkeys(win,'^{Home}+{Right 520}',FALSE);
win_api_shell.sendkeys(win,'+{Right 501}',FALSE);

It higlights the entire text and the freezes the screen. So it doesn't work.
While the code below takes me to the 1021 character within the text item.

win_api_shell.sendkeys(win,'^{Home}+{Right 1021}',FALSE);

It doesn't like two win_api_shell.sendkeys statements.
I am not sure what to do.

Rajesh

Re: Cursor manipulation within a text item [message #168536 is a reply to message #168510] Thu, 20 April 2006 20:56 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Quote:

I do not know the valid values for the second parameter. Do you have a URL?
Obviously I got my parameters wrong. What does '^' do? What does '+' do? What other 'things' can exists between '{' and '}'?

David
Re: Cursor manipulation within a text item [message #168541 is a reply to message #168536] Thu, 20 April 2006 21:37 Go to previous messageGo to next message
ashishmate
Messages: 90
Registered: February 2005
Location: Mumbai
Member

Hi
You can use edit_textitem builtin it gives serch option by default;

ASHish...

Re: Cursor manipulation within a text item [message #168548 is a reply to message #168541] Thu, 20 April 2006 22:50 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Please give URL or cut and paste reference material to support your post.

David
Re: Cursor manipulation within a text item [message #168552 is a reply to message #168541] Thu, 20 April 2006 23:00 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Sorry ... do you mean the Ctrl-F (Find) facility once you get the item open?

David
Re: Cursor manipulation within a text item [message #169436 is a reply to message #167199] Wed, 26 April 2006 17:02 Go to previous messageGo to next message
rcd70
Messages: 14
Registered: April 2006
Location: Auckland, New Zealand
Junior Member
Hi David

I have no url as the form is used is inhouse. I got a sample code from google and used it. ^,+,% are all modifiers used for Shift = +; Control = ^; Alt = %.
I have placed the code on the when-new-item-instance for the text item.

DECLARE
/* Variable to store the window handle to the window from which we want the Operating system to interact.*/
win pls_integer;
total_len Number;
start_num Number;
search_num Number;
BEGIN

IF :control.search_string = 'YES' THEN
total_len := length(rtrim(ltrim(:sys_bls.bls_message)));
start_num := INSTR(:sys_bls.bls_message,rtrim(ltrim(:control.search)));
search_num := (total_len - start_num) + 1;
/*Test to see if the current item is a text item so we do not try to move to the end of a button.*/
IF get_item_property(:system.current_item, item_type) = 'TEXT ITEM' then
/*Get Window Handle and initialize it to our pls integer variable*/
win := get_window_property(forms_mdi_window, WINDOW_HANDLE);
win_api_shell.sendkeys(win,'^{Home}+{Right '||start_num||'}',FALSE);
END IF;
END IF;
END;

Rajesh
Re: Cursor manipulation within a text item [message #169453 is a reply to message #169436] Wed, 26 April 2006 22:09 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I meant a url to the meaning of the '+^%' commands. If '+' means 'shift', then I would expect that '+{Right 10}' would highlight 10 characters. Is this correct?

Instead of
win_api_shell.sendkeys(win,'^{Home}+{Right 520}',FALSE);
win_api_shell.sendkeys(win,'+{Right 501}',FALSE);
please try
win_api_shell.sendkeys(win,'^{Home}{Right 520}',FALSE);
win_api_shell.sendkeys(win,'{Right 501}',FALSE);
win_api_shell.sendkeys(win,'+{Right 10}',FALSE);
does this set of commands cause the cursor to highlight 10 characters a 1000 or so characters into the item?

Do you really need to use Ctrl-Home or will Home get you to the beginning of the item?

David
Re: Cursor manipulation within a text item [message #169634 is a reply to message #167199] Thu, 27 April 2006 17:52 Go to previous messageGo to next message
rcd70
Messages: 14
Registered: April 2006
Location: Auckland, New Zealand
Junior Member
Hi

Here is the url for the info on sendkeys
http://www.rpi.edu/AFS/home/41/bailem2/rt/campus/oracle/developer/6.0/sun4x_56/doc60/admin/help/US/pjbhelp7.htm#pjb01368

Control Home needs to be used to go to the beginning of the text.

I tried the code you mentioned but the screen freezes, same result result as earlier.

I was trying to use another solution but I need some information on the text item for that. Is there a way of finding out how many lines are there in a multi text item and how many characters each line has.

Thanks
Rajesh


[Updated on: Mon, 01 May 2006 21:06] by Moderator

Report message to a moderator

Re: Cursor manipulation within a text item [message #169939 is a reply to message #169634] Sun, 30 April 2006 21:30 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
A multi-line text item still has only one string of data. What is the data type of your field? If varchar2, then use the length function to determine its size. Use instr on chr(12) (or whatever) to find the line breaks. If the field is a 'long' or 'blog' then use the package for handling that type of field.

David
Re: Cursor manipulation within a text item [message #169968 is a reply to message #169939] Mon, 01 May 2006 01:48 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Remember to have the item's 'Keep Cursor Position' set to 'Yes' so that after you have done 1024 movements you can do a 'previous item' then 'next item' so you end up at the same point in the multi-line text field and can then do another 1024 movements.

David
Re: Cursor manipulation within a text item [message #170046 is a reply to message #167199] Mon, 01 May 2006 20:46 Go to previous messageGo to next message
rcd70
Messages: 14
Registered: April 2006
Location: Auckland, New Zealand
Junior Member
Hi David

I tried your suggestions, but I could not get it working.

win_api_shell.sendkeys(win,'^{Home}{Right '||right_no||'}',FALSE);
message('kkkkkkkkkkkkk');pause;
:control.search_string := 'NO';

If I give any instructions after the win_api_shell.sendkeys line, it does not work even if the string is less than 1023 characters. The entire text gets highlighted and the cursor is at the end of the text.

I believe after executing the win_api_shell.sendkeys line, the program loses control.ie. it cannot execute the lines thereafter.

Your suggestions.

Rajesh
Re: Cursor manipulation within a text item [message #170050 is a reply to message #170046] Mon, 01 May 2006 21:35 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Please try it without the Ctrl-Home and make sure that there are more characters in the field than 'right' movements.

David
Re: Cursor manipulation within a text item [message #300864 is a reply to message #167199] Mon, 18 February 2008 06:26 Go to previous messageGo to next message
rjsha1
Messages: 22
Registered: December 2005
Location: Birmingham England
Junior Member
does this same code work in 10g.
Re: Cursor manipulation within a text item [message #300867 is a reply to message #300864] Mon, 18 February 2008 06:51 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Try and you'll know.
Re: Cursor manipulation within a text item [message #300957 is a reply to message #300867] Mon, 18 February 2008 18:09 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
According to the 'web_util' documentation "Only the Win_API_Environment package has been ported along with some
dependent packages."

So for 10g you will have to use Java thingies. Look at "PJC and Java Bean Samples available as part of the Forms Demos" on http://www.oracle.com/technology/sample_code/products/forms/index.html

David
Previous Topic: To perform check on text item
Next Topic: Issue in formweb.cfg using Sun JVM
Goto Forum:
  


Current Time: Fri Sep 27 10:33:28 CDT 2024