Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6206

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

From Chris Degnen <degnen@cwgsy.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: {Keydown,"c"} event in graphics
Date 2011-11-05 09:56 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j9317h$ad4$1@smc.vnet.net> (permalink)
References <j90h73$sn1$1@smc.vnet.net>

Show all headers | View raw


On Nov 4, 11:10 am, nico...@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)]]

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

{Keydown,"c"} event in graphics nicolas@virtualdynamics.fr - 2011-11-04 11:10 +0000
  Re: {Keydown,"c"} event in graphics Silvia <wyelen@gmail.com> - 2011-11-05 09:49 +0000
  Re: {Keydown,"c"} event in graphics Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-11-05 09:52 +0000
  Re: {Keydown,"c"} event in graphics Chris Degnen <degnen@cwgsy.net> - 2011-11-05 09:56 +0000
    Re: {Keydown,"c"} event in graphics nicolas@virtualdynamics.fr - 2011-11-06 10:59 +0000

csiph-web