Can I access keys by their names
|
07-24-2016, 07:06 PM
Post: #1
|
|||
|
|||
Can I access keys by their names
So far when I have wanted to check for a user key, I have checked for that keys HP number, thus IF KK==4 for ESC.
If you have a lot of keys to check for, or in the interests of portability, an alternative would be preferred. I had thought to use the key name (listed under user key customisation), but that name is giving me a syntax error if I simply replace the "4" with "K_Esc". Code:
Am I missing something obvious to use those key names for checking for keys? Or is there a better way? Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
07-25-2016, 11:41 PM
(This post was last modified: 07-25-2016 11:41 PM by Tim Wessman.)
Post: #2
|
|||
|
|||
RE: Can I access keys by their names
There is not any way to do this apart from numbers. The problem basically boils down to not wanting to create "nice names" for every possible variable option in the system. You'd probably be adding another 500 reserved words or so.
The reason it doesn't work is quite simple - 4 is not equal to a string. What people normally do, is put in a comment or similar. IF KK==4 THEN // K_Esc TW Although I work for HP, the views and opinions I post here are my own. |
|||
07-26-2016, 05:12 AM
(This post was last modified: 07-26-2016 05:36 AM by Tyann.)
Post: #3
|
|||
|
|||
RE: Can I access keys by their names
Bonjour
Voici ce que j'ai mis en place sur ma machine si cela peut vous être utile. Hello Here's what I 've put on my machine While this may be useful . Code:
Toutes ces affectations sont à mettre dans un programme. Vous pouvez écrire ensuite : All these assignments are put in a program. You can then write : Code:
To access variables : VAR button , User menu, option : name of the program Sorry for my english |
|||
07-26-2016, 08:27 AM
Post: #4
|
|||
|
|||
RE: Can I access keys by their names
(07-26-2016 05:12 AM)Tyann Wrote: Hello ... all these EXPORT variables require some memory. A sort of #define or #const keyword which would simply define a placeholder would be more memory efficient. On the other hand there seems to be plenty of memory, so why care? Martin |
|||
07-26-2016, 08:26 PM
(This post was last modified: 07-26-2016 08:47 PM by StephenG1CMZ.)
Post: #5
|
|||
|
|||
RE: Can I access keys by their names
(07-25-2016 11:41 PM)Tim Wessman Wrote: There is not any way to do this apart from numbers. The problem basically boils down to not wanting to create "nice names" for every possible variable option in the system. You'd probably be adding another 500 reserved words or so. When you said 4 is not equal to a string, I thought K ESC was a string. But MSGBOX(STRING(K_Esc,)) Doesn't work - which could have been useful if you wanted to say "Press Escape to Escape" but refer to the key name consistently: "Press "+K_Esc+" to Escape". As an alternative to having 50 Exports, I was considering having one Export - effectively a list. Whilst accessing a list would likely be less efficient than a constant, it minimises the number of exports, and also the list sequence associates a number with the key - which might be useful for the keys 0..9 0..F or A..Z. Code:
Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
07-26-2016, 08:39 PM
(This post was last modified: 07-26-2016 08:59 PM by Tim Wessman.)
Post: #6
|
|||
|
|||
RE: Can I access keys by their names
(07-26-2016 08:26 PM)StephenG1CMZ Wrote: When you said 4 is not equal to a string, I thought K ESC was a string. What I meant is that if you are doing something like 4 == "K_Esc", it is always false because the string "K_Esc" is not equal to the numerical value 4. There is no mapping exposed between the names used in the user key definitions, and the numerical values. We've thought about several possibilities, but never have found one that we really liked yet. TW Although I work for HP, the views and opinions I post here are my own. |
|||
07-26-2016, 09:56 PM
(This post was last modified: 07-26-2016 09:59 PM by StephenG1CMZ.)
Post: #7
|
|||
|
|||
RE: Can I access keys by their names
Thanks for that explanation Tim.
And thanks Tyann and Martin. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
08-12-2016, 06:33 PM
(This post was last modified: 08-12-2016 06:43 PM by StephenG1CMZ.)
Post: #8
|
|||
|
|||
RE: Can I access keys by their names
I would like to suggest a useful feature: Some way of enabling or highlighting a list of keys from within a program.
An earlier version of my Periodic Table program allowed the user to choose how to select an element: "Symb" key to input Au, "Enter" to enter "gold", etc. I needed some way of reminding the users which keys were implemented. Given the current technology, I tried DRAWMENU("Symb","Enter").. This listed the keys, but was confusing - so far, my program has no touch interface, so instead of tapping Symb on-screen you have to hit the Symbol key. What I really wanted was a command like ENABLEKEYS({"Symb","Enter"}) that on the emulator would highlight the keys the keys that the user can use in some way. On the real hardware that would not be possible, so one would need a way of bringing up a helpful choose list on-screen: ENABLEKEYS({""Symb","Press Symb to input symbol"}) etc. Some users might find it much easier to select from a choose list of a limited number of usable keys, than to hunt for those keys over the full keyboard. Of course, I could pop-up such a list on--screen myself in response to some key or other... But then each program's mechanism for accessing the key prompt would be different.... Nicer to have a standard key, and one able to change the colour of the emulator keys too. Also possible, would be an option for keys not enabled to be ignored by GETKEY/ISKEYDOWN. My latest version of the program eliminates most keypad entry and uses a choose list instead, but highlighting keys in use would still be useful. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
08-19-2016, 02:57 PM
(This post was last modified: 08-19-2016 03:50 PM by Fortin.)
Post: #9
|
|||
|
|||
RE: Can I access keys by their names
(08-12-2016 06:33 PM)StephenG1CMZ Wrote: Also possible, would be an option for keys not enabled to be ignored by GETKEY/ISKEYDOWN. If the desire is for these functions to ignore key presses that you don't care about, then ISKEYDOWN may have new functionality that could help. ISKEYDOWN includes a feature in 10077 that returns a 64bit value (one bit per key) so you are able to see multiple key presses with one function call. If you then bitwise AND with a proper mask, you can filter out disabled keys. For example, if you wanted to detect View (9) and Enter (30), you could create a mask of #40000200:64h (2^9 + 2^30). To create this mask, something like this works well: SETBASE(BITSL(#1b,9)+BITSL(#1b,30),4) BITAND(ISKEYDOWN(-1),#40000200:64h) will return a mask containing only the keys of interest that are pressed. |
|||
08-19-2016, 03:36 PM
Post: #10
|
|||
|
|||
RE: Can I access keys by their names
(07-26-2016 08:39 PM)Tim Wessman Wrote:(07-26-2016 08:26 PM)StephenG1CMZ Wrote: When you said 4 is not equal to a string, I thought K ESC was a string. How about making the key names constant values (like the value of Pi)? DISPLAY K_Esc would display 4 Tom L Tom L Cui bono? |
|||
08-26-2016, 06:19 PM
Post: #11
|
|||
|
|||
RE: Can I access keys by their names
(08-19-2016 02:57 PM)Fortin Wrote:(08-12-2016 06:33 PM)StephenG1CMZ Wrote: Also possible, would be an option for keys not enabled to be ignored by GETKEY/ISKEYDOWN. Yes, that mask would do what I was thinking of when I suggested ignoring keys not enabled. i had been thinking of a user interface more like ENABLEKEYS({4},True) or ENABLEKEYS({K_ESC},True) where True=ignore other keys, but ANDing a mask is good too. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)