Swallow a keyup
-
This is a part 2 on a question i posted earlier on this forum. The problem: In a Keydown handler, when a user pressed the VK_MENU key an editbox is created. So far so good. Problem is that the standard behaviour of windows for a KEYUP-message of this key is to open a context menu. I was suggested: 1) to create the editbox in the keyup handler. This is not an option. 2) to swallow the keyup-message. This sounds good. My question: how to swallow the keyup message? Is it setting up a local message dispatcher that dispatches messages till the keyup event comes in view, and then just trow it away? What happens to the keyboardstate then? I'm using C. A light on the right approach would be welcome... Rozis
-
This is a part 2 on a question i posted earlier on this forum. The problem: In a Keydown handler, when a user pressed the VK_MENU key an editbox is created. So far so good. Problem is that the standard behaviour of windows for a KEYUP-message of this key is to open a context menu. I was suggested: 1) to create the editbox in the keyup handler. This is not an option. 2) to swallow the keyup-message. This sounds good. My question: how to swallow the keyup message? Is it setting up a local message dispatcher that dispatches messages till the keyup event comes in view, and then just trow it away? What happens to the keyboardstate then? I'm using C. A light on the right approach would be welcome... Rozis
If you're fixated on WM_KEYDOWN, rather than WM_KEYUP, you have another problem to consider. When someone holds down a key, you get multiple down messages, followed by a single up message. Are you requiring someone to hold down the menu button? If not, what's wrong with using the UP message? If you are requiring they hold down this button, then a) typing will be hard, and b) you could use the up button to dismiss your edit box. Answering your question more directly, if you can handle the down message, can't you just handle the up message with 99% identical code:
case WM_KEYDOWN:
if (wParam == VK_MENU)
DoSomething ();
else
DoAnotherThing ();
break;case WM_KEYUP:
if (wParam == VK_MENU)
;
else
DoYetAnotherThing ();
break;You say you're using C, so I assume some win32 code stuff. Yours trying to help but puzzled why your tying your shoe laces together, Iain.
I have now moved to Sweden for love (awwww).
-
This is a part 2 on a question i posted earlier on this forum. The problem: In a Keydown handler, when a user pressed the VK_MENU key an editbox is created. So far so good. Problem is that the standard behaviour of windows for a KEYUP-message of this key is to open a context menu. I was suggested: 1) to create the editbox in the keyup handler. This is not an option. 2) to swallow the keyup-message. This sounds good. My question: how to swallow the keyup message? Is it setting up a local message dispatcher that dispatches messages till the keyup event comes in view, and then just trow it away? What happens to the keyboardstate then? I'm using C. A light on the right approach would be welcome... Rozis
I've been curious and looked at your previous question. I've made a small app, and it has an edit box. Both right clicking in the edit box, and pressing the menu key end up generating a WM_CONTEXTMENU message. *This* is what pops up the menu. You could subclass the edit window in question, and handle the WM_CONTEXTMENU message for that window. Handle it by doing very little. The details of how you do that vary a lot depending on what programming framework you are using. Iain.
I have now moved to Sweden for love (awwww).
-
I've been curious and looked at your previous question. I've made a small app, and it has an edit box. Both right clicking in the edit box, and pressing the menu key end up generating a WM_CONTEXTMENU message. *This* is what pops up the menu. You could subclass the edit window in question, and handle the WM_CONTEXTMENU message for that window. Handle it by doing very little. The details of how you do that vary a lot depending on what programming framework you are using. Iain.
I have now moved to Sweden for love (awwww).
Hi Iain, Thank you for your answers, and the time to get the answer. Of course you're right about the button down vs button up. I have to reconcider that. But actually you found out how it really works (WM_CONTEXTMENU). So i'll track that one and throw in the void... Thanks again Rozis