Hi,
how can I define my own code blocks for some standard keys, e. g. K_RIGHT, , K_LEFT, K_DEL, or K_CTRL_DEL, in a xBrowse?
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
Hi,
how can I define my own code blocks for some standard keys, e. g. K_RIGHT, , K_LEFT, K_DEL, or K_CTRL_DEL, in a xBrowse?
You can't use codeblocks, but you can try redefining them at the top of xbrowse.prg and compiling and linking it with your application. The downside is that you will have to update this with each new version of FWH.
I don't recommend redefining these keys as they are standards and your users will be confused by it, and probably not happy.
James
Don't know if you can trap left, right etc but you can do this:
oBrw:bKeydown := { | nKey | BrowseKeys(nKey) }
STATIC FUNCTION BrowseKeys(nKey)
IF nKey == VK_F3
ENDIF
RETURN NIL
Regards,
Pete
James,
thank you for the quick answer.
I agree with your opinion, regarding the standard navigation keys as follows: K_RIGHT, K_LEFT, K_UP, K_DOWN, K_PGUP, K_PGDN, K_HOME, K_END, ... So I will not redefine these keys.
But what about these keys: K_DEL, K_CTRL_DEL, K_INS, K_CTRL_INS, ... These keys were not trapped by 'oBrw:bKeyChar', though the have no function inside xBrowse! Why?
I also don't understand the reason why the keys K_CTRL_HOME and K_CTRL_END have the same function as K_HOME and K_END. I have a lot of browses with an active OrdScope() and hoped that I could use these keys to change the scope of the table to the first, respectively to the last range.
Frank,
My apologies for saying you couldn't use a codeblock, I had a brain fade and forgot about bKeydown.
Can I see the codeblock you have defined, and function you are using to trap the keys?
James
STATIC FUNCTION My_Keys( oBrw, nKey )
  IF nKey >= 97 .AND. nKey <= 122
   nKey := Asc( Upper( Chr( nKey ) ) )
  ENDIF
 Â
  IF nKey == K_CTRL_F .OR. nKey == Asc( Upper( "F" ) )
   //
   // Filter setzen
   //
   IF GetKeyState( VK_CONTROL )
     My_Filter_FiveWin( oBrw )
   ENDIF
  ELSEIF nKey == K_CTRL_RETURN .OR. nKey == VK_RETURN
   //
   // Edit all marked records
   //
   IF GetKeyState( VK_CONTROL )
     My_Edit_Dialogbox_FiveWin( oBrw )
   ENDIF
  ELSEIF nKey == K_CTRL_S
   //
   // Toggle security flag
   //
   Toggle_Schutz()
  ELSEIF nKey == K_DEL .OR. nKey == VK_DELETE
   //
   // Delete records
   //
   IF GetKeyState( VK_CONTROL )
     MsgInfo( "The function for the key 'Strg-Entf' (K_CTRL_DEL) is not yet implemented!" )
   ELSE
     MsgInfo( "The function for the key 'Entf' (K_DEL) is not yet implemented!" ) )
   ENDIF
  ELSEIF nKey == K_INS .OR. nKey == VK_INSERT
   //
   // Insert
   //
   IF GetKeyState( VK_CONTROL )
     MsgInfo( "The function for the key 'Strg-Einfg' (K_CTRL_INS) is not yet implemented!" )
   ELSE
     MsgInfo( "The function for the key 'Einfg' (K_INS) is not yet implemented!" )
   ENDIF
  ELSEIF nKey == VK_CONTROL .OR. nKey == VK_RETURN
   //
   // Do nothing
   //
  ELSE
    //MsgInfo( "The function for the key '" + AllTrim( Str( nKey ) ) + "' is not yet implemented!" )
  ENDIF
RETURN nKeyFrank,
Yes the two methods, KeyDown() and KeyChar(), do make it more confusing. Perhaps Antonio can explain why there are two? It is probably a Windows thing.
I don't think the "K_" values are necessary--they are either reduntant to the "VK_" values or not used (remember, unlike Harbour, in FW everything goes through the Window event handler. You may note that there are no "K_" values used in FW's own code.
I do agree it would be nice to have one codeblock that we could use to trap all keys (or, at least most keys, since Windows does not allow trapping of certain keys like F1, F10, etc.).
As an alternative interface idea, consider making a right-click pop-up menu with all your options on it. This is a Windows standard and users will automatically try this. Unless your users are expert users that use the program a lot, they will not remember the hot-keys. At the very least consider doing both. All hot-key options should also be on a menu anyway for less than expert users.
James
As an alternative interface idea, consider making a right-click pop-up menu with all your options on it. This is a Windows standard and users will automatically try this. Unless your users are expert users that use the program a lot, they will not remember the hot-keys. At the very least consider doing both. All hot-key options should also be on a menu anyway for less than expert users.
When I create a menu for Child window, it automatically replaces main menu when Child window has focus. You can also have a toolbar on each window.
Gale,
thank you for the tip, which direct me in the right direction.