From: Bruce S. <Bru...@nc...> - 2008-12-07 16:25:46
|
Information about crtl, alt, and shift is part of scene.mouse; see the documentation on handling mouse events. Also, keyboard events need not block, just as mouse events need not block. scene.kb.keys is nonzero if there is a keyboard event waiting to be processed, just as scene.mouse.events is nonzero if there is a mouse event wating to be processed. Here is an example: scene.range=10 s = sphere(radius=0.5) while 1: rate(100) m = scene.mouse # dragging with mouse buttons up s.pos = m.pos if m.alt: s.color = color.red elif m.ctrl: s.color = color.cyan elif m.shift: s.color = color.yellow if scene.kb.keys: k = scene.kb.getkey() if k == 'b': s.color = color.blue elif k == 'g': s.color = color.green I'm guessing that what you mean by your final question is whether it is possible to specify a function to be called when an event occurs, rather than watching for an event in a loop, as in the routine above. The answer is no; you have to detect events in a loop. Bruce Sherwood Stef Mientki wrote: > hello, > > I would like to detect if one of the special keys, > like Ctrl-Alt-Shift changes during mouse dragging. > > As far as I can see, > this doesn't seem possible, > because > - those keys don't generate a mouse event > - waiting for a key event blocks the dragging > Is this correct ? > > A more general question is: > is it possible to detect key or mouse events, > without waiting to happen ? > > thanks, > Stef > > ------------------------------------------------------------------------------ > SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. > The future of the web can't happen without you. Join us at MIX09 to help > pave the way to the Next Web now. Learn more and register at > http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |