Why does the Tab key fire KeyUp but not KeyDown

Posted by: j2associates on 8 September 2017, 12:32 pm EST

  • Posted 8 September 2017, 12:32 pm EST

    Hello,


    Any ideas on this one?

  • Replied 8 September 2017, 12:32 pm EST

    Did a bit more digging...


    How to fire KeyDown or KeyUp while pressing TAB in a Windows Forms control by using Visual Basic .NET or Visual Basic 2005: http://support.microsoft.com/kb/327821


    By default, the KeyDown event and the KeyUp event do not fire for a control when you press TAB. However, the KeyUp event is fired for the next control that receives focus.

  • Replied 8 September 2017, 12:32 pm EST

    Hello,

    I beleive the issue is related to the default inputmap of Spread. I think it's probably consuming the keystroke.

    This forum thread may be of help in understanding this:
    http://www.clubfarpoint.com/Forums/forums/thread/22117.aspx

    The later posts by bobbyo may answer your questions.

    Quoted from Bobbyo: "you would need to override the the ProcessDialogKey method (which
    requires a new class to be derived from the existing FpSpread class)."

    Also, here is a link to a section of our online help that also gives some info on this:
    http://www.clubfarpoint.com/FarPointSupportSite/Modules/docs/SpreadWin2.5-VS2005/spwin-mapskeysyswin.html
  • Replied 8 September 2017, 12:32 pm EST

    j2associates,


    In the DotNet framework, keystrokes can be consumed in the ProcessDialogKey/Char methods, the OnKeyDown/Press/Up methods, and the KeyDown/Press/Up events.  When a keystroke is consumed in the ProcessDialogKey/Char methods, the DotNet framework skips the corresponding OnKeyDown/Press/Up methods and KeyDown/Press/Up event.  The ProcessDialogKey/Char methods occur when the control or its child controls have focus.  The OnKeyDown/Press/Up methods and KeyDown/Press/Up events only occur when the control have focus.  The spreadsheet needs to consume many navigational keystokes (e.g. TAB, PAGE UP/DOWN, HOME/END, etc) both when the spreadsheet has control and when a cell edit child control has focus.  Thus, the spreadsheet consumes these keystrokese in the ProcessDialogKey/Char methods which means that there is no corresponding OnKeyDown/Press/Up methods or KeyDown/Press/Up events.


    The spreadsheet has a WhenAncesotorOfFocused input map that lists keystrokes consumed in the ProcessDialogKey/Char methods.  The spreadsheet has a WhenFocused input map that lists keystrokes consumed in the OnKeyDown/Press/Up events.  By default, the TAB keystroke is listed in the WhenAncestorOfFocused input map.


    To prevent the spreadsheet from consuming the TAB keystroke in the ProcessDialogKey method, you have several options.


    Option 1: Override the spreadsheet's ProcessDialogKey method.


    Option 2: Bind the TAB keystroke to the None action in the spreadsheet's WhenAncestorOfFocused input map.  This will prevent the spreadsheet from consuming the TAB keystroke.


    Option 3: Bind the TAB keystroke to the MoveToNextColumnWrap action in the spreadsheet's WhenFocused input map.  The TAB keystroke will now be listed in both the WhenFocused and WhenAncestorOfFocused input maps (with the WhenFocused input map having priority when the spreadsheet has focus).  This will cause the spreadsheet to consume the TAB keystroke in the OnKeyDown event (which fires the KeyDown event) when the spreadsheet has focus but continue to consume the TAB keystroke in the ProcessDialogKey method when a cell editor child control has focus.


    Note: If using option 2 or option 3, you still may have to worry about the Form consuming the TAB keystroke (which could also prevent the KeyDown event from firing).


    Bobby

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels