-
January 7th, 2020, 21:48 #1
Trying to get a stringfield to lose focus.
I've figured out that I should use the Escape key to make a control lose focus, but I still don't understand why this piece of code wouldn't work:
Code:<script> function onClickDown(nButton, _, _) if nButton == 1 then if hasFocus() == true then setFocus(false); end end end </script>
-
January 7th, 2020, 22:34 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
Ruleset scripts are processed before standard processing. So, the focus isn’t set until after your script returns.
If you don’t want the standard processing to occur after your script, you need to “return true”.
Also, if you just want to block UI interaction, then use readonly or disabled tags.
Regards,
JPG
-
January 7th, 2020, 22:55 #3
No, my code wasn't meant to block interaction. I figured that I click once to set the focus, then type something in the field, and then click once more to unfocus it, since I can't use Enter to finish.
...but maybe the "standard processing" you mentioned, then quickly refocuses the field again. Maybe "return true" would have prevented that, if i understood you correctly. Thank you.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks