Re: {Keydown,"c"} event in graphics
- To: mathgroup at smc.vnet.net
- Subject: [mg122692] Re: {Keydown,"c"} event in graphics
- From: nicolas at virtualdynamics.fr
- Date: Sun, 6 Nov 2011 05:55:55 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <j90h73$sn1$1@smc.vnet.net> <j9317h$ad4$1@smc.vnet.net>
On 5 nov, 10:56, Chris Degnen <deg... at cwgsy.net> wrote: > On Nov 4, 11:10 am, nico... at virtualdynamics.fr wrote: > > > Does any body knows how to set a key down event for "c" for an event > > handler wrapped around a graphics object ? > > > The "c" is associated by the front end to the creation of a circle, > > and i need this key and others shortcuts for other tasks. > > > EventHandler[Graphics[{}], {"KeyDown", "c"} :> ( (* does not work *) > > Beep[])] > > > Thanks Nicolas > > You could comment-out the drawing tools command section in > SystemFiles\FrontEnd\TextResources\Windows\KeyEventTranslations.tr > if that's not too inconvenient. Or add modifiers. Hello Chris It seems to be the only way to do, but it is not appropriated to edit the KeyEventTranslations.tr file directly. - Is there a way to temporary edit it at the runtime, I mean by a frontend command, like it is possible for MenuSetup.tr ? - In KeyEventTranslations.tr there are type filters. Is there a way to change the BoxClass of graphics objects so that the GraphEdit2D object shortcuts are not associated with the object ? > > The letter "b" is not used in the drawing tools commands, so > it works fine in the demo below. > > Note, the graphics has to be selected before the KeyDown can > be received. (MouseDown works more easily.) > > DynamicModule[{counter = 0, > colour = RGBColor[29/85, 29/85, 29/85], > cols = ColorData[6, "ColorList"]}, > Dynamic[ > EventHandler[Graphics[{colour, Rectangle[{0, 0}, {7, 8}]}, > PlotRange -> {{0, 7}, {0, 8}}, ImageSize -> 200], > {"KeyDown", "b"} :> (colour = > cols[[Mod[counter = ++count, 10] + 1]])], > Initialization :> (count = counter)]]