Menu handling with hardware keys

Discussion in 'Questions (Windows Mobile)' started by miklquick, Jul 11, 2007.

  1. miklquick

    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.

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    The Windows Mobile OS do not support this.
    You will need to use other controls (maybe a ComboBox).
  3. agraham

    agraham Expert Licensed User

    Why not attach a context menu to a Form (as this example), or a large control? When the user presses it with his finger the context menu comes up and he can navigate it and accept his selection using the buttons.
  4. agraham

    agraham Expert Licensed User

    Sorry - I'm sure that I uploaded the zip but it didn't appear. Finger trouble probably - here it is.
  5. RandomCoder

    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.


    Attached Files:

  6. agraham

    agraham Expert Licensed User

    Maybe it's because formlib.dll is not in the same directory. It needs it as it uses a context menu. I should have made that clear. Sorry.
  7. agraham

    agraham Expert Licensed User

    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.
  8. RandomCoder

    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???

  9. agraham

    agraham Expert Licensed User

    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.

    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!
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice