Page 1 of 2
Struggling Handling Focus of 1 field
Posted: Tue Jul 17, 2012 10:57 am
by doobox
Hi there,
I have a palette stack with 1 entry field(userEmailAddress) and 1 drop-down select(checkInterval).
When the stack opens i don't want anything focused.!
easy:
Code: Select all
on openStack
focus on nothing
end openStack
on resumeStack
focus on nothing
end resumeStack
So i can focus on the entry field fine. But i cant lose the focus when clicking away, or selecting the dropdown list object.
There does not seem to be any message related to the field when clicking away after it has been focused.
I have tried all kinds of crazy handlers like on the card:
Code: Select all
on mouseUp
if not (word 2 of the target is "userEmailAddress") then
focus on nothing
end if
end mouseUp
This is heading in one right direction, but unveils many more handlers would be needed to cover many other possible user actions.
I am sure there is a really simple way to handle this, as fields would be mixed with other controls in most cases for collecting user input, but for the life of me i cant see it.
Kind regards
Gary
Re: Struggling Handling Focus of 1 field
Posted: Tue Jul 17, 2012 11:54 am
by Dixie
Gary...
Would...
Code: Select all
on mouseLeave
focus on nothing
end mouseLeave
help at all ?
be well
Dixie
Re: Struggling Handling Focus of 1 field
Posted: Tue Jul 17, 2012 11:59 am
by doobox
Thanx Dixie, But i dont think that will be suitable really.
That would give a really odd behavior.
If the user clicked in and got focus, just before they were about to start typing, there cursor left the field, they would need to click back in.
Re: Struggling Handling Focus of 1 field
Posted: Wed Jul 18, 2012 2:14 am
by dunbarx
Not sure I completely understand, but how about "closeField, "focusOut" or "exitField"?
Craig Newman
Re: Struggling Handling Focus of 1 field
Posted: Wed Jul 18, 2012 9:03 am
by LittleGreyMan
Hi,
As Craig, not sure I understand what you're trying to achieve.
But if it's just a display issue, did you try scripting the showFocusBorder of the field instead of controlling the focus?
Re: Struggling Handling Focus of 1 field
Posted: Wed Jul 18, 2012 9:13 am
by doobox
If i palette a substack that has just 1 card, 1 text field, and 1 dropdown select.
Without any additional coding or amendment to the objects properties.
The field gets focus on opening... "normal and expected".. but on clicking away from the field
there is no message sent : closeField, exitField, or focusOut.
I must have done something in another stack, card or object, outside this new substack. Because if i test this with a new test project, this behavior is not seen.
And i do see a message on clicking away from the field.
I am obviously catching the messages somewhere. urghh..
So if i have an on exitField handler on a field script in the main stack for example. Must i pass that message...?
Code: Select all
on exitField
// doo stuff
pass exitField
end exitField
If i dont pass this message. would this issue be expected.?
Re: Struggling Handling Focus of 1 field
Posted: Wed Jul 18, 2012 9:43 am
by doobox
Sussed it
It was due to the fact i had a graphic covering the entire background of the stack.
So when clicking outside the field the graphic was catching the click, and expected messages were not being sent.
removed the graphic and all works as expected

Re: Struggling Handling Focus of 1 field
Posted: Sun Jun 16, 2013 5:30 pm
by palanolho
OK, I'm having the same problem.
SO, what i need (as doobox explained) is to:
I'm fulfilling an input box, then, I click outside of that input box (anywhere, even if its another control, image or whatever) and that makes the input box lose the focus.
As doobox told, if I click on TAB key or click on an empty space on my card (with no component or image below) it works, however, I have lots of images and controls on my card and it will be difficult not to click on one.
What I'm trying to do is to pass the value of the input box to another input box when I click outside of it.
Anyone has any idea how I can do this??
Many thanks
Re: Struggling Handling Focus of 1 field
Posted: Sun Jun 16, 2013 6:03 pm
by dunbarx
If I understand, you want to put the contents of a field into another field whenever you click outside that field? Try this in the field script:
Code: Select all
on mouseLeave
watchForClick
end mouseLeave
on watchForClick
if the mouse is down then
put random(99) into fld 2
cancel item 1 of the last line of the pendingmessages
exit to top
end if
send "watchForClick" to me in 1
end watchForClick
Now I did this with two fields, and just put a random number into the second field. i am sure you can modify this to accommodate your particular case. This has the advantage that is makes no difference where the mouse is when you click.
Craig Newman
Re: Struggling Handling Focus of 1 field
Posted: Sun Jun 16, 2013 6:26 pm
by palanolho
I tried your scrip on the field that I'm editing, but It doesn't work for me

I tried to click on a rectangle or on an image, and nothing
Also, I wound like to make this the default behaviour of my application, since its the default behaviour in most applications and websites.
Is it possible to do this?
many thanks
Re: Struggling Handling Focus of 1 field
Posted: Sun Jun 16, 2013 6:40 pm
by dunbarx
I tested in a new stack with only the two fields on it. Try that. It will work, and then we have to figure out what is stopping it from working in your stack.
Craig Newman
Re: Struggling Handling Focus of 1 field
Posted: Sun Jun 16, 2013 6:45 pm
by palanolho
I also tried like you said, and it works, the problem is when i click in an area not empty.
for example, when i click on an image or rectangle graphic (for example)
Re: Struggling Handling Focus of 1 field
Posted: Sun Jun 16, 2013 7:23 pm
by jacque
Maybe all the field needs is a "closefield" handler. It will get that whenever you click outside of it. In the closefield handler, move the data to the other field. Then you don't need any mouseup handlers at all.
Re: Struggling Handling Focus of 1 field
Posted: Sun Jun 16, 2013 8:17 pm
by dunbarx
Palanolhol:
I see no difference where I click. In any graphic, any object of any kind or anywhere on the card. In, fact, you can click outside the window and it will still work.
Jacque
Cleaner and simpler. You would need an "exitField" as well, if nothing was changed.
Craig
Re: Struggling Handling Focus of 1 field
Posted: Sun Jun 16, 2013 8:24 pm
by jacque
An exitField might be useful, though if nothing was changed, the second field might not need an update. I guess it depends on what the stack is doing.