strokes interface



Hi!

I have been using lately a EDA CAD toolset that has a realy nice
feature: it implements mouse strokes in all the programs in the
toolset.

How does it work? You click the middle button of the mouse and then
drag it as you were drawing something, a thin line is drawn on the
screen, when you release the button the line is erased and the shape
you have drawn is matched against some predifined shapes, if it
matches one of the an acction associated with that shape is executed.

As an example a horizontal line drawn from right to left could mean
"Cancel",  one drawn from left to right could mean "Ok", one at 45
degree could mean "Zoom in", and one at 45 degree in the oposite sense
could mean "Zoom out". 

This is useful in very complex CAD packages, you won't need to go to a
toolbar, and pick a tool all the time (which means that you have to
move the mouse from the place on the screen were you are working if
you have a stroke that picks the last tool you used, or zooms in and
out, or undo, redo etc.). Even doing a right-click and then picking
something from a menu is not as easy, as it distracts your
attention. Or in a web browser if you have some strokes that do:
forward, backward, etc. you won't have to reach for the toolbar, you
can have the mouse anywhere.

This is implemented in Emacs-20.[23] and XEmacs-20.x (is anybody
suprised?) 
(this is the reason I cc-ed David Bakhash, he is the author of that
package, and he has done complex stuff with it, like chinese character
input using strokes). 

To try this feature in emacs just do:
M-x strokes-mode RET
M-x load-file RET test.el RET

--test.el cut here--
;;   -*- Syntax: Emacs-Lisp; Mode: emacs-lisp -*-
(setq strokes-global-map '((((8 . 4)
			     (7 . 4)
			     (6 . 4)
			     (5 . 4)
			     (4 . 4)
			     (3 . 4)
			     (2 . 4)
			     (1 . 4)
			     (0 . 4))
			    . kill-buffer)
			   (((0 . 4)
			     (1 . 4)
			     (2 . 4)
			     (3 . 4)
			     (4 . 4)
			     (5 . 4)
			     (6 . 4)
			     (7 . 4)
			     (8 . 4))
			    . switch-to-buffer))
      )
--test.el up to here--


with this if you draw a horizontal line with the middle button from
right to left it will kill the current buffer, if you do it from left
to right it will switch to another buffer. 

You can define your own strokes with: 
M-x global-set-stroke

How does the stroke recognition works? You match the figure drawn
against a matrix. 

For a 3x3 matrix, using a notation like phone pad:

 1 2 3 
 4 5 6
 7 8 9

a "456" stroke is a horizontal line from left to right.
a "258" stroke is a vertical line

I have put some screenshots from the tool that uses strokes on the web
at:
http://www.ics.uci.edu/~dann/strokes1.jpg
http://www.ics.uci.edu/~dann/strokes2.jpg

I think that having strokes implemented in GTK would be a very good
thing, and have a few strokes defined by default (like one for Ok and
one Cancel), then the applications could define more specialized
strokes. 
It should not be too hard to implement it (the implementation in Emacs
is less than 1000 lines of elisp code, well if this is a valid
comparison...) 
Probably the hardest problem is to decide how to represent the strokes
(I like the phone pad notation, but it is limited...) and to have an
interface to define strokes. 

What do you think about this? 

--Dan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]