Subject Re: key or Onkey event
From Mustansir Ghor <mustan31@hotmail.com>
Date Sun, 24 Sep 2023 12:06:11 -0400
Newsgroups dbase.getting-started

Dear Mervyn Sir

Thanks to You, Ken Sir and Heinz

The matter is very clear now. As we programmer will always use best route to reach the goal.

Regards
Mustansir


Mervyn Bick Wrote:

> On 2023/09/23 22:16, Mustansir Ghor wrote:
> > Dear Heinz
> >
> > I am Entering a Value in Combobox and wish to force Action with Tab Key.  But when I press Enter Key It triggers Change event first so the condition for key event to look for Tab key only does not work.
> >
>
> It used to be common practice to use a combobox's onChange event handler
> to execute code depending on the selection made.  This has its problems
> as the event fires every time the user uses the arrow keys to move
> through the dropdown list.  Eventually dBASE added the onChangeCommitted
> event to address this.
>
> It's not a problem if the user only uses the mouse to make a selection
> in the combobox dropdown list but a combobox's onChange event fires
> every time a new value is highlighted in the dropdown list.  In other
> words, if the user uses the up and down arrows to move through the list,
> the onChange event fires each time a new value is highlighted.  If the
> user presses Enter then the onChangeCommitted event fires.  This has
> made the programmer's life much simpler.
>
> The combobox's key and onKey events do not fire when the up and down
> arrows are used. Except when the list contains only single character
> entries, when any other key is pressed (including the Backspace nChar =
> 8, Tab nChar = 9  and Enter nChar = 13) the key event fires followed by
> the onKey event.
>
> The key event fires before a character is passed on the dBASE.  It is,
> therefore, possible to use the key event handler to "swallow" keystrokes
> that one doesn't want the combobox to see.  To disable the Backspace key
>
>     function COMBOBOX1_key(nChar, nPosition,bShift,bControl)
>        local lRet
>        if nChar = 8 //Backspace
>          lRet = false
>        else
>          lRet = true
>        endif
>        return lRet
>
> Although it is normal to use either the onChange or the
> onChangeCommitted event handler to implement the user's selection in the
> combobox you don't have to use either of these two events at all.  You
> could just as easily use the onKey event handler instead.
>
>    function COMBOBOX1_onKey(nChar, nPosition,bShift,bControl)
>       if nChar = 9 //Tab
>         if this.value = 'Some'
>            //Appropriate code
>         elseif this.value = 'Thing'
>            //Appropriate code
>         elseif this.value = 'Else'
>            //Appropriate code
>         endif
>       endif
>       return
>
> Mervyn.
>
>
>
>
>
>



Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0