Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ease-dev] Button Keylistener Python

I didn't test it, but there is a method getUiEvent() (found using the
Modules Explorer view). You can call it in the callback. Maybe you can
call it in your callback() method to distinguish between a click, key
pressed etc...

Yvan Lussaud.

Le jeudi 09 janvier 2025 à 13:32 +0100, Raphael Geissler a écrit :
> Hi Yvan,
> 
> you're right. This was not correct, but it does not solve the error
> with the MyKeyListener class.
> 
> Do you have any idea how I have to implement this key listener class?
> 
> BR,
> 
> Raphael
> 
> Am Do., 9. Jan. 2025 um 13:28 Uhr schrieb Yvan LUSSAUD
> <yvan.lussaud@xxxxxxx>:
> > 
> > Hi Raphael,
> > 
> > You need to write the code of the call back as a String:
> > 
> > button = createButton('DoIt', 'callback()')
> > 
> > regards,
> > Yvan Lussaud.
> > 
> > Le jeudi 09 janvier 2025 à 13:03 +0100, Raphael Geissler via ease-
> > dev a
> > écrit :
> > > Hi *,
> > > 
> > > does anyone know, how I can add a key listener to a button within
> > > a
> > > Python EASE Script. I tried following, but I get following error.
> > > 
> > > Code:
> > > -----------------------------------------------------------------
> > > ----
> > > ------------------
> > > # name : Keylistener Example
> > > loadModule('/System/UI Builder')
> > > 
> > > def callback():
> > >     print('Button clicked')
> > > 
> > > class MyKeyListener(org.eclipse.swt.events.KeyListener):
> > >     def keyPressed(self, event):
> > >         print("Key pressed:", event.character)
> > > 
> > >     def keyReleased(self, event):
> > >         print("Key released:", event.character)
> > > 
> > > createView('Example')
> > > 
> > > button = createButton('DoIt', callback)
> > > button.addKeyListener(MyKeyListener())
> > > -----------------------------------------------------------------
> > > ----
> > > ------------------
> > > 
> > > Error:
> > > -----------------------------------------------------------------
> > > ----
> > > ------------------
> > > org.eclipse.ease.ScriptExecutionException: Traceback (most recent
> > > call last):
> > > File "workspace://ease/working/keylistener_example.py", line 9,
> > > in
> > > <module>
> > > # Jonah Graham (Kichwa Coders) - initial API and implementation
> > > TypeError: JavaClass.__init__() takes 3 positional arguments but
> > > 4
> > > were given
> > > -----------------------------------------------------------------
> > > ----
> > > ------------------
> > > 
> > > Maybe someone has an idea what I do wrong...
> > > 
> > > BR,
> > > 
> > > Raphael
> > > _______________________________________________
> > > ease-dev mailing list
> > > ease-dev@xxxxxxxxxxx
> > > To unsubscribe from this list, visit
> > > https://www.eclipse.org/mailman/listinfo/ease-dev
> > 



Back to the top