[GRASS-dev] new profiling tool and other gis.m updates

Glynn Clements glynn at gclements.plus.com
Mon May 22 04:34:12 EDT 2006


Trevor Wiens wrote:

> > Maciek Sieczka wrote:
> > 
> > > > > > the left hand is
> > > > > > I for zoom In
> > > > 
> > > > Oops Z for Zoom in (not S)
> > > 
> > > Don't use z or y keys - due to qwerty vs qwertz keyboards.
> > 
> > Any key bindings should be read from a configuration file to allow for
> > this sort of issue.
> 
> I totally agree and if someone can point me in the right direction I
> will do it.

In Tk, event bindings are done with the "bind" command, e.g.:

	# Redraw changes
	bind .mapcan($mon) <KeyPress-c> {
		MapCanvas::request_redraw $mon 0
	}
	# Zoom to current and redraw everything
	bind .mapcan($mon) <KeyPress-space> {
		MapCanvas::zoom_current $mon
	}

The simplest approach would be to have a file which stores the event
sequences in an array, then have any bind commands use that, e.g.:

bindings.tcl:

	set bindings(mapcan_redraw) <KeyPress-c>
	set bindings(mapcan_zoom) <KeyPress-space>

	...

	# allow user to override bindings
	source $env(HOME)/.gis.m/bindings.tcl

Other Tcl files:

	source $gmpath/bindings.tcl

	...

	global bindings

	bind .mapcan($mon) $bindings(mapcan_redraw) {...}
	bind .mapcan($mon) $bindings(mapcan_zoom) {...}

This should be done for key and mouse events, but not "system" events
such as Configure, Destroy, FocusIn, etc.

Note that Tk allows some abbreviations. E.g. Key/KeyPress can be
omitted if the keysym is given, so <KeyPress-Escape> can be
abbreviated to <Escape>. Button/ButtonPress can be omitted if the
button number is given, so <ButtonPress-1> can be abbreviated to <1>.

For clarity, I would suggest avoiding the use of these abbreviations
in the code, using the most explicit form instead.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list