Possible to disable Enter key in find mode?

Questions and answers for designing and implementing forms in Servoy

Possible to disable Enter key in find mode?

Postby jditte » Thu Jul 21, 2011 7:44 pm

Is it possible to disable/inactivate the Enter key in find mode? I want my user to be able to start a search only by pushing a particular button (because I am processing the contents of the form fields before starting the search) and not by hitting the Enter key (which can easily happen with inexperienced users).

Thanks,

Jochen
jditte
 
Posts: 6
Joined: Mon Jul 18, 2011 12:28 am

Re: Possible to disable Enter key in find mode?

Postby bobcusick » Thu Jul 21, 2011 9:21 pm

Why not just hook up the script that you want to run to the enter key action?

In Servoy, there's no way to trap for a keypress (in the native application - you can do it with Java and creating your listeners) - but you CAN control what happens when the form searches.

On your form - double-click on the event "onSearch" - click "Create Form Method". Then view the script of the form (right click and choose "Open in script editor"). Call your method from the "onSearch" method and it will trigger when they hit the enter key in find mode.
User avatar
bobcusick
 
Posts: 126
Joined: Mon Jan 12, 2009 9:13 pm

Re: Possible to disable Enter key in find mode?

Postby jditte » Thu Jul 21, 2011 10:27 pm

Thank you, Bob. That would probably allow me to make sure that my script runs before the search is performed, but it would not prevent starting a search prematurely when inadvertently hitting the Enter key while filling out multiple fields. Thus, my preference would still be to disable the Enter key, but it sounds like it is impossible to break the link between hitting the Enter key and starting the search.(?)

Jochen
jditte
 
Posts: 6
Joined: Mon Jul 18, 2011 12:28 am

Re: Possible to disable Enter key in find mode?

Postby Harjo » Fri Jul 22, 2011 9:53 am

I'm doing this out of my head, but can't you just check, if you activated the onSearch() script by the Enter key or by a button.. (like setting some variable when you fired it from a button) and if the variable is not filled, you say, return false?

again, not sure, if: return false
works for onSearch....
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Possible to disable Enter key in find mode?

Postby jcompagner » Fri Jul 22, 2011 10:09 am

wouldn't it just work if you overwrite onsearch and do nothing, and then when the button is pressed you do you search?
As far as i know onsearch event is only triggered by the UI not when you do it through scripting..
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Possible to disable Enter key in find mode?

Postby jditte » Fri Jul 22, 2011 8:30 pm

Thanks for the tips! It is actually as easy as just calling an empty method when onSearch is triggered. I didn't think of that because my expectation was that onSearch would just call a method that is being executed before Servoy starts the search. I didn't expect that the search itself would be started by the method...
jditte
 
Posts: 6
Joined: Mon Jul 18, 2011 12:28 am

Re: Possible to disable Enter key in find mode?

Postby Joas » Mon Jul 25, 2011 10:22 am

jditte wrote:Thanks for the tips! It is actually as easy as just calling an empty method when onSearch is triggered.

You can also set the onSearch event to "none", then you don't need an empty method.
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: Possible to disable Enter key in find mode?

Postby amcgilly » Wed Mar 28, 2012 7:10 pm

There's some useful additional info about this issue in this thread:

viewtopic.php?f=2&t=17989
Adrian McGilly
Servoy Developer

Image
amcgilly
 
Posts: 375
Joined: Fri Dec 09, 2005 12:03 am
Location: San Francisco, CA


Return to Forms

Who is online

Users browsing this forum: No registered users and 6 guests