COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 07-13-2016, 01:23 AM   #1
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 236
Default OnKeyDown never called

I try to use OnKeyDown(int x, int y, int key) on my custom control, but this function not work in my case, never called.
SaschArt is offline   Reply With Quote
Old 07-13-2016, 01:29 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Which platform, which host? Do you click on the control with the mouse before trying the keypress? Which keys are you trying to use? (At least in the Windows implementation of IGraphics, there's only a limited set of keys that will be passed in to OnKeyDown.)

edit : Yet another thing to consider. Did you use the correct signature for the overridden OnKeyDown method? It needs to return a bool, so it's different from the mouse methods that don't have a return value.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 07-13-2016 at 04:37 AM.
Xenakios is offline   Reply With Quote
Old 07-13-2016, 07:21 AM   #3
jack461
Human being with feelings
 
jack461's Avatar
 
Join Date: Nov 2013
Location: France
Posts: 181
Default

Quote:
Originally Posted by SaschArt View Post
I try to use OnKeyDown(int x, int y, int key) on my custom control, but this function not work in my case, never called.
I'm working on Mac with Xcode. I have a control with the following declaration in the "MyControl" class:
Code:
virtual bool OnKeyDown(int x, int y, int key);
And this is the code:
Code:
bool MyControl::OnKeyDown(int x, int y, int key)
{
    switch(key)
    {
        case KEY_LEFTARROW :
            deltaX = -8; dlx = deltaX*CellWidth;
            break;
        case KEY_RIGHTARROW:
            deltaX = 8; dlx = deltaX*CellWidth;
            break;
        ...
    }
    return true;
}
In the WDL implementation, you can only use letters, numbers and arrows (see in IPlugStructs.h).

(I have actually changed the implementation in IGraphicsCocoa.mm and IGraphicsCarbon.cpp to have access to all keyboard keys, and the modifiers key too, which works correctly).
jack461 is offline   Reply With Quote
Old 07-13-2016, 09:44 AM   #4
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 236
Default

Quote:
Originally Posted by Xenakios View Post
Which platform, which host? Do you click on the control with the mouse before trying the keypress? Which keys are you trying to use? (At least in the Windows implementation of IGraphics, there's only a limited set of keys that will be passed in to OnKeyDown.)

edit : Yet another thing to consider. Did you use the correct signature for the overridden OnKeyDown method? It needs to return a bool, so it's different from the mouse methods that don't have a return value.
Windows, Tale edition of WDL, yes I click on control and no call at all. In Tale edition OnKeyDown is void, in IControl.h exactly like this: virtual void OnKeyDown(int x, int y, int key) {}

Code from my custom control:
Code:
	void OnKeyDown(int x, int y, int key) {
	OutputDebugString("OnKeyDown");
		if (right_click) {
			right_click = false;
		}
	}

Last edited by SaschArt; 07-13-2016 at 09:51 AM.
SaschArt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:52 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.