Keyboard Short-Cuts


Author
Message
Scott Bressette
Scott Bressette
StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)
Group: Forum Members
Posts: 17, Visits: 53
We have several clients that heavily use keyboard short-cuts and they noticed that they are missing from key areas of Strataframe controls. In particular, the Maintenance Toolstrip lacks even the common Ctrl-S to save let alone navigation short-cuts. The BrowseDialog doesn’t have any accelerator keys to get from the search area to the list and then to Ok and Cancel quickly, without a mouse.



I know that I could add them myself but it would improve the "out of the box" experience of StrataFrame if I didn't have too. Is there a reason you didn't include them (localization or something)? Or, am I just missing the global “TurnOnKeybordShortCuts=True” property?

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I agree that this would be a nice enhancement. However, note that for the maintenance form toolstrip, it wouldn't actually be added there, but rather at the form level. Why? Because if the toolstrip handled the shortcuts, they would only work if the toolstrip was receiving the key presses. I.e. if the user was in a text box and hit the keyboard shortcut, the maintenance form toolstrip wouldn't know about it. However, key presses bubble up to parent controls, so if you handled the shortcut at the form level, it would work great.



It is easy to implement though. Typically, you override the ProcessCmdKey method on the form. Then you'd use a select case (switch in C#) statement to test for the various keys and then call whatever methods. The following would implement save and new short cuts:



Protected Overrides Sub ProcessCmdKey(msg As System.Windows.Forms.Message _

            , keyData As System.Windows.Forms.Keys)

  '-- Track if the key is handled here

  Dim keyHandled As Boolean = False



  '-- Handle any configured keyboard shortcuts

  '   Note that these are the same methods used by the

  '   SF MaintenanceFormToolstrip

  Select Case keyData

    Case Keys.Control Or Keys.S

      '-- Clt + S. Use SF StandardForm Save method...saves all configured BOs

      Me.Save()

    Case Keys.Control Or Keys.N

      '-- Clt + N. Use SF STandarForm Add method

      Me.Add()

  End Select



  '-- If key was handled, set message result, if not use base processor

  If keyHandled Then

    '-- Trent says this is a good idea...not sure why or what this is, but...

    msg.Result = IntPtr.Zero

  Else

    keyHandled = MyBase.ProcessCmdKey(msg, keyData)

  End If



  '-- Return if key was handled

  Return keyHandled

End Sub




Hope that helps!
Scott Bressette
Scott Bressette
StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)StrataFrame Novice (55 reputation)
Group: Forum Members
Posts: 17, Visits: 53
Greg,



That's an excellent answer. I'll do that in my base form. That way, it work regardless of what save option I am providing.



Thanks,

Scott
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Exactly! BigGrin
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
That is a great answer Greg...and totally correct! BigGrin Not that you were ever doubted!



Just to add one thing in regards to the BrowseDialog. You have pretty much total control over this as well. You can set the shortcut keys for the AcceptKey, CancelKey, and SearchKey. But you can also force the focus to the results after a query is performed by setting the SetFocusToResultsAfterSearch property to True. Then after that it is just a matter of user the arrow keys to find the record and a Ctrl+Enter (by default) to accept the selected row.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search