Menu handling with hardware keys

miklquick

Member
Licensed User
I want to write an application which uses menus for opening different forms for use in rough environment and want to avoid using the stylus but rather the hardware keys for going through the menu.

Upon pressing the "hardware enter key" I want the child menu to appear just as if the word at the left bottom edge of the form had been pressed by the stylus.

And with the "hardware up key" and "hardware down key" I want to scroll through the child menu until I reach the selected child menu item. Just as on a desktop scrolling through a menu with the up/down buttons.

By pressing the hardware enter key I want to raise the click event just as if the child menu item had been marked with the stylus.

Who can help me.
 

Attachments

RandomCoder

Well-Known Member
Licensed User
I've tried agraham's example but nothing seemed to happen, is this just on my device:confused:

Anyway, attached is some code that I've written to overcome your little problem.

Basically I've hidden a panel with three labels representing the menu items.
Press the Enter hardware button to display the Menu.
Up and Down to scroll through the menu choices.
Enter again to select the highlighted menu item or Left to close the menu.
Alternatively you can add another level of menu which could be accessed using a Right click.

Hope you like it. If it was possible to draw lines on a panel then I could have made it even more like the real menu which by the way still works.

Regards,
RandomCoder
 

Attachments

agraham

Expert
Licensed User
If it was possible to draw lines on a panel then I could have made it even more like the real menu which by the way still works.
You could put a white panel on top of a slightly bigger black panel then put the labels on the white panel. That gives the appearance of a black border.
 

RandomCoder

Well-Known Member
Licensed User
Nice tip, I hadn't thought of doing it like that.

PS. I have the FormLib.dll included in the application folder but still nothing happens???

Regards,
RandomCoder
 

agraham

Expert
Licensed User
Nice tip, I hadn't thought of doing it like that
This is the way I get bordered panels in the full Compact Framework - an idea I stole from someone else! I have since realised that in this case, when the panel is full of controls anyway, the white panel is probably superfluous if the controls are carefully placed to touch each other.

PS. I have the FormLib.dll included in the application folder but still nothing happens???
It's dead simple code, just a context menu bound to the form itself rather than a control. Ah! are you "touching" or "stabbing" rather than "pressing"? If you press then you get the round circle of dots then the context menu pops up. Same as right-click on the desktop.

You're way is neater than mine in that it uses the Enter key to bring up a menu but only lets you have one pop-up menu on the form. I hadn't looked at the hardware component properly. I knew that you could get some hardware key presses but didn't realise that the navigation keys were included in those.

Aging but still learning all the time!
 
Top