From: Bruce S. <Bru...@nc...> - 2008-12-07 22:24:32
|
I say again that as is documented, and exploited in the routine I posted, scene.mouse.alt etc. CAN be examined during a drag. Here's a more complex version of the routine, in which you have to hit the sphere in order to begin to drag, and during the drag you can change the color of the sphere by ctrl, alt, or shift (or press b or g), or change the color back to white by releasing the key. scene.range=10 s = sphere(radius=0.5) drag = False while 1: rate(100) m = scene.mouse if m.events: mm = scene.mouse.getevent() if mm.drag and mm.pick is s: drag = True elif mm.drop: drag = False if drag: 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 else: s.color = color.white if scene.kb.keys: k = scene.kb.getkey() if k == 'b': s.color = color.blue elif k == 'g': s.color = color.green Why do you say that these keys can't be detected during a drag, when this routine and the previous routine I posted show them being detected? I'm confused. It is true that keyboard events do not include pressing ctrl or alt of shift by themselves: they are modifiers of other keys. Bruce Sherwood Stef Mientki wrote: > thanks Bruce, > > Bruce Sherwood wrote: >> Information about crtl, alt, and shift is part of scene.mouse; see the >> documentation on handling mouse events. > But as far as I can see: > - the status of Ctrl / Alt doesn't change if there's no mouse event, i.e > when dragging an object. > - Ctrl / Alt isn't catched by the keyboard event >> 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. > Thanks, I didn't read that correct . >> 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. >> > No, but you gave the answer above, > > cheers, > Stef >> 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 >> > > ------------------------------------------------------------------------------ > 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 |