We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › ControlP5: disable dragging control elements
Page Index Toggle Pages: 1
ControlP5: disable dragging control elements? (Read 1789 times)
ControlP5: disable dragging control elements?
May 19th, 2009, 12:28am
 
Hi,
I have just finished my first project with Processing, but there is one tiny problem with ControlP5, which seems to only affect Linux, because I can't reproduce it under Mac.
I'm using a separate control window with a textfield. Everything works fine until I hit the Alt+Tab key to switch to another program. When I switch back to my application and click on the control window, I can drag the control elements without pushing the Alt key. Furthermore, I can't get focus on the textfield.
To stop this I have to push the Alt key again.
As workaround I'd like to disable dragging of control elements completely. Is there a way to do that?
Re: ControlP5: disable dragging control elements?
Reply #1 - May 19th, 2009, 5:42am
 
ok, will add a enable/disable drag with next version. for now i cant give you a good workaround.
best,
andreas
Re: ControlP5: disable dragging control elements?
Reply #2 - May 19th, 2009, 7:34am
 
Hi Andreas,

thanks for responding. That would be really great, because in the meantime I found out that this issue also occurs under Windows (Vista).
When using the Alt-Tab combo the Alt key event is constantly sent to the processing window, although it is in the background. And it keeps on doing that when you pull it back to the foreground until you hit the Alt key once again, as I already mentioned in my first post. So I would guess that it is a more general problem of the OS or Processing.

Sascha.
Re: ControlP5: disable dragging control elements?
Reply #3 - May 21st, 2009, 6:51am
 
i've contributed a patch over at openprocessing.org that illustrates how to trap keyboard events and request that they not be re-transmitted. it might be useful in your case - i believe it could be modified to prevent the rebroadcasting of the alt key to controlp5 once it's captured by a custom KeyEventDispatcher. see this link for more information: http://openprocessing.org/visuals/?visualID=1132
Re: ControlP5: disable dragging control elements?
Reply #4 - May 22nd, 2009, 3:52am
 
Thanks for that. I'll give it a try.

Sascha.
Re: ControlP5: disable dragging control elements?
Reply #5 - May 26th, 2009, 9:24am
 
It seems like I worked it out. Quite simple, although it looks like a dirty hack. Here is what I did:

Quote:
void setup(){
 //Keyboard dispatcher
    k = new Keyboard();
    KeyboardFocusManager.getCurrentKeyboardFocusManager() 
    .addKeyEventDispatcher( k ); 
}

class Keyboard implements KeyEventDispatcher

  Keyboard() 
  { 


  public boolean dispatchKeyEvent( KeyEvent ke )
  { 
    int kc = ke.getKeyCode();
    if ( kc == 18 )  //18 = Alt key
    {
      return true;
    }
    else {
      return false;  //retarget key event to application
    }
  } 



Maybe somebody can use that, too.

Best,
Sascha.
Page Index Toggle Pages: 1