Login  Register

Re: TrakEM2 help on keyboard shortcuts

Posted by Albert Cardona-2 on Oct 16, 2020; 2:34pm
URL: http://imagej.273.s1.nabble.com/TrakEM2-help-on-keyboard-shortcuts-tp5024072p5024075.html

The code of course had problems, as it wasn't tested: should have been
addMouseMotionListener, and also, no mouse movement is detected
outside the canvas itself. So the code would have to be adjusted for
that.

Missatge de Albert Cardona <[hidden email]> del dia dv., 16 d’oct.
2020 a les 14:01:

>
> Hi Bohumil,
> I've looked into the TrakEM2 source code, and:
>
> F11 selects the pen tool;
> F12 selects the brush tool.
>
> See:
> https://github.com/trakem2/TrakEM2/blob/master/src/main/java/ini/trakem2/utils/ProjectToolbar.java#L267
>
> If these aren't convenient, it's easy to create other ways to activate
> the pen tool or the brush tool. For example, you could create a mouse
> listener that recognizes a gesture, which could be e.g. moving back
> and forth within a corner or a screen, or something similarly easy
> such as moving your mouse to a corner of the screen. I.e., in jython:
>
> ```
> from ini.trakem2.display import Display
> from java.awt.event import MouseAdapter
>
> class ToolToggle(MouseAdapter):
>   def __init__(self):
>     self.outside = True
>   def mouseMoved(self, event):
>     x, y = event.getXOnScreen(), event.getYOnScreen()
>     if x < 100 and y < 100: # top left corner
>       if self.outside: # only toggle if mouse was outside
>         self.outside = False # prevent toggling until mouse is moved
> outside and back in
>         if ProjectToolbar.getToolId() == ProjectToolbar.PEN:
>           ProjectToolbar.setTool(ProjectToolbar.BRUSH)
>         else:
>           ProjectToolbar.setTool(ProjectToolbar.PEN)
>     else:
>       self.outside = True
>
> front = Display.getFront()
> front.getCanvas().addMouseListener(ToolToggle())
> ```
>
> Run the script from the Script Editor after opening TrakEM2, and your
> upper left corner will be a toggle between both tools. All you have to
> do is move the mouse there.
>
> Haven't tested the above script, hopefully errors if any are obvious.
>
> Hope this helps.
>
> Albert
>
> Missatge de Bohumil Maco <[hidden email]> del dia dv., 16
> d’oct. 2020 a les 12:48:
> >
> > Dear Experts,
> >
> > Please, can somebody help me with my following issue: I am using TrakEM2 to
> > proofreading and editing my neuronal network segmentation output and I am
> > using a graphical tablet and pen and I need very often to use area list
> > selection tool and paint brush tool....which is not very convenient using
> > table pen to select them from the TrakEM2 tools bar.
> >
> > I was searching without any success to create and use keyboard short cuts
> > to quickly select them and to switch between them.
> >
> > Is there a way to create a keyboard shortcuts to quickly select the
> > selection tool and paint brush in TrakEM2?
> >
> > Any suggestions are welcome while it will save me a lot of time  and make
> > the error editing process faster.
> >
> > Thank you very much for any advice.
> >
> > Cheers,
> >
> > Bohumil
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html