5E Product Walkthrough Playlist
  1. #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>
    Have I typed it wrong? It feels like setFocus() isn't even working here.

  2. #2
    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

  3. #3
    Quote Originally Posted by Moon Wizard View Post
    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
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in