Source language: Translate to:

Window focus

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Window focus

Postby Wrangler » Wed Jul 19, 2006 8:12 am

I'm using a customwindow containing comboboxes containing data. When the user selects an item from a combobox, I want the data to be pasted into the textentry box that is selected (blinking cursor in it). The user would select the textentry box, and then select an item in the combobox and it is pasted with sendkeys. The problem is, when you select an item in the combobox, the focus is no longer on the main pub window, but the customwindow, and no paste. How can I set the focus back to the main window, and still have the cursor in the desired textentry box?

Using this code:

SetVar "[clipboard]" "[autofillname]"
../ set focus here?
SendKeys "" "{CtrlDn}v{CtrlUp}"
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby beno » Wed Jul 19, 2006 9:07 am

Hi Wrangler,

I made a little example with your idea and set this code in the "Selection changed" combo box action:

Code: Select all
SetVar "[clipboard]" "[autofillname]"
FocusObject "TextEntry1"
SendKeys "" "{CtrlDn}v{CtrlUp}"


And is working nice for me.

TextEntry1 is on the main window and my combobox is in a custom window.

HTH,

beno
User avatar
beno
 
Posts: 678
Joined: Fri Apr 01, 2005 9:03 am
Location: México

Postby Wrangler » Wed Jul 19, 2006 9:19 am

Thanks for the response, Beno. This won't work, because it focuses the textentry1 object, and I have no way of knowing which textentry box the user will choose. I either need to know which textentry box the user has his cursor in, and focus to it, or just focus the main window, as the user has already put the cursor into a textentry box.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby Wrangler » Wed Jul 19, 2006 9:35 am

I could use BringAppToFront, if I could get the app ID for the main window. Any ideas?
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby beno » Wed Jul 19, 2006 9:39 am

Hi Wrangler,

Ok, I got it now: you have several text entry objects (I did not read carefully the first time).

Here is another idea:

Put a button over each text entry, when the user push this button, then it assings the text entry name to a variable, then it sends the button back, so when the user selects from the combobox in the custom window you know exatly where to paste the info.

Not a very good idea, lots of details to polish. But I did it and it works...

HTH

beno
User avatar
beno
 
Posts: 678
Joined: Fri Apr 01, 2005 9:03 am
Location: México

Postby Gaev » Wed Jul 19, 2006 10:08 am

Wrangler:

There is a Global (Read only) variable ...
Code: Select all
[FocusedObject] The name of the object that has the input focus.
... and you can define special routines to be invoked with Custom Windows (:ObjectName_OnOpen and :ObjectName_OnClose) ... so you can capture value of [FocusedObject] ... and save it in your own variable in the ObjectName_onOpen routine ...
Code: Select all
SetVar "[FocusedTextEntryBox]" "[FocusedObject]"


By the way, you don't need to revert to SendKeys to update the contents of the focused textEntry Box ... as long as the variables to contain the contents of the TextEntry Boxes have some consistent relationship with the objects' names (which is the default), you can ...
Code: Select all
SetVar "[[FocusedTextEntryBox]]" "[autofillname]"
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Wrangler » Wed Jul 19, 2006 12:17 pm

Thanks, Gaev. I tried [FocusedObject], but didn't know about :ObjectName_OnOpen and :ObjectName_OnClose. Can you give me an example of how to use them to set the focus to the main window and the selected textentry box?
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby Wrangler » Wed Jul 19, 2006 1:53 pm

Oops. Sorry, Gaev. Updated my help file for nb, and found it in there. Will play with it now that I've got something to go on.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby Gaev » Wed Jul 19, 2006 1:55 pm

Wrangler:
Can you give me an example of how to use them to set the focus to the main window and the selected textentry box?
... I thought I just did ... above ... but here are some details ...

a) Say your TextEntryBox objects are TextEntry11, TextEntry22 and TextEntry33 ... their respective Variable: (to store TextEntry contents) are (by default) [TextEntry11], [TextEntry22] and [TextEntry33].

b) So your objective is to populate the variable associated with the "focused TextEntry" object with the contents of the selected ComboBox entries ... assuming this is [autofillname].

c) So user clicks inside one of the TextEntry objects ... which make it the object with Focus ; then, he/she causes the CustomWindow to be popped up ... say by clicking on a Button ? ... but before the CustomWindow pops up, NeoBook services the :ContainerX_onOpen subroutine ... assuming ContainerX is the object containing your ComboBoxes ...so ...
Code: Select all
:ContainerX_onOpen
SetVar "[FocusedTextEntryBox]" "[FocusedObject]"
Return
... causes it to save the name of the TextEntry object in [FocusedTextEntryBox] ... let us say this is TextEntry22.

d) So, after you decide that the contents of [autofillname] need to be placed in the last focused TextEntry Box ...
Code: Select all
SetVar "[[FocusedTextEntryBox]]" "[autofillname]"
... note the double brackets ... this causes NeoBook to do a double substitution ... first (starting from the inside out and using our example of TextEntry22), it translates it to SetVar "[TextEntry22]" "[autofillname]" ... and of course this results in contents of variable [autofillname] being placed in the variable [TextEntry22] ... which happens to be the variable reserved to reflect the contents of object TextEntry22 ... and so NeoBook replaces the text in this object with the contents of [autofillname].

As long as the CustomWindow is popped up, user can keep clicking on different ComboBoxes inside the Container ... and as long as there are ... SetVar "[[FocusedTextEntryBox]]" "whatever" ... type commands within their "Selection Changed" routines, TextEntry22 will have its text updated from the selected entry of the ComboBox.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Wrangler » Wed Jul 19, 2006 2:07 pm

I did find more info on it in the help file, after upgrading it as I posted above just when you posted. You couldn't have splained it better. You efforts are not wasted, however, because I'm under the gun to get this project finished, and you've just saved me the time to figure out what you've explained above. The example in the help file wasn't helping me much.

Thanks! :wink:
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby Wrangler » Wed Jul 19, 2006 5:58 pm

For some reason, I can't get this to work. I have this code:

Subroutine:

:groupautofill_onOpen
SetVar "[FocusedTextEntryBox]" "[FocusedObject]"
Return

In button that opens custom window:

GoSub "groupautofill_onOpen"
CustomWindow "AutoFill" "494" "31" "groupautofill" "NoBorder"

In combobox selection changed:

SetVar "[[FocusedTextEntryBox]]" "[autofill1]"

(I have changed [autofillname] to [autofill1]) Nothing appears in the textentry box.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby Gaev » Wed Jul 19, 2006 7:14 pm

Wrangler:
In button that opens custom window:

GoSub "groupautofill_onOpen"
CustomWindow "AutoFill" "494" "31" "groupautofill" "NoBorder"
... you don't need the GoSub ... when you invoke the CustomWindow command, NeoBook automatically services any subroutine with a matching name (with the _onOpen suffix).
(I have changed [autofillname] to [autofill1]) Nothing appears in the textentry box.

a) just before the ...
Code: Select all
SetVar "[[FocusedTextEntryBox]]" "[autofill1]"
... insert ...
Code: Select all
AlertBox "autofill1" "[autofill1]"
AlertBox "FocusedTextEntryBox" "[FocusedTextEntryBox]"
... which should tell you what the contents of the variables are just before you try and update them.

Is [Autofill1] ? what you expected ? If not, when you changed the name of the ComboBox, did you also change its Variable to store Selected Item as well ?

Is [FocusedTextEntryBox] what you expected it to be ? i.e. TextEntry object with the blinking pipe-character ? If not, what is it ?

BTW, if you have a button that invokes the CustomWindow, you don't need the _onOpen routine at all ... just do the SetVar "[FocusedTextEntryBox]" "[FocusedObject]" command immediately before the CustomWindow command.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Wrangler » Wed Jul 19, 2006 7:37 pm

Is [Autofill1] ? what you expected ? If not, when you changed the name of the ComboBox, did you also change its Variable to store Selected Item as well ?

As expected.

Is [FocusedTextEntryBox] what you expected it to be ? i.e. TextEntry object with the blinking pipe-character ? If not, what is it ?

As expected.

Nothing is happening in the textentry box.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby Wrangler » Wed Jul 19, 2006 7:44 pm

Here it is. The selected textentry box variable is [database.produrl]. If I use a regular variable, such as [textentry1], it works. The combobox data is sucked from a text file. So, what would cause a database variable to not work?
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby Gaev » Wed Jul 19, 2006 7:45 pm

Wrangler:

I set up a small pub to replicate this ... worked for me ... BUT ...

a) make sure that a TextEntryBox is REALLY selected before you invoke the CustomWindow ... a TextEntryBox with its content "selected" does NOT necessarily have focus ... the blinking pipe-character does.

So, in order to help your user, you may want to make sure that the [FocusedTextEntryBox] variable contains the value of one of the valid TextEntry objects BEFORE you invoke the CustomWindow command ...
Code: Select all
SearchStr "[FocusedTextEntryBox]" "TextEntry11,TextEntry22,TextEntry33" "[SearchPos]"
If "[SearchPos]" "=" "0"
   ... not valid
Else
    CustomWindow ...
    ....
EndIf


b) User has to make a change to the selection of an entry in a ComBoBox, in order for its onChange event to be triggered ... which should then update the contents of the focused TextEntry Box.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Next

Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests