MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: {Keydown,"c"} event in graphics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122678] Re: {Keydown,"c"} event in graphics
  • From: Chris Degnen <degnen at cwgsy.net>
  • Date: Sat, 5 Nov 2011 04:48:54 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j90h73$sn1$1@smc.vnet.net>

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.

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)]]




  • Prev by Date: Re: Impossible to move objects in dynamic graphics
  • Next by Date: Re: iteration question
  • Previous by thread: Re: {Keydown,"c"} event in graphics
  • Next by thread: Re: {Keydown,"c"} event in graphics