Topics

Strange error with event_typedCharacter


Alberto Buffolino
 

Hi all,
I'm working on an appModule for an Eclipse/Java-based application (RSSOwlnix, specifically).
In AppModule class, I have this method:
***
def event_typedCharacter(self, ch):
obj = api.getFocusObject()
if obj.role == ct.ROLE_TREEVIEWITEM:
ui.message("set as read/unread")
obj.setFocus()
***
it should force a gainFocus event on current treeview item, but the problem is that, when I press "m" over the treeview item in the application, I get this error:
***
WARNING - eventHandler._EventExecuter.next (15:30:03.031) - MainThread (12084):
Could not execute function event_typedCharacter defined in appModules.rssowlnix module; kwargs: {'ch': 'm'}
Traceback (most recent call last):
File "eventHandler.pyc", line 105, in next
TypeError: event_typedCharacter() got multiple values for argument 'ch'
ERROR - eventHandler.executeEvent (15:30:03.032) - MainThread (12084):
error executing event: typedCharacter on <NVDAObjects.Dynamic_TreeViewItemOutlineItemIAccessible object at 0x07D0E390> with extra args of {'ch': 'm'}
Traceback (most recent call last):
File "eventHandler.pyc", line 246, in executeEvent
File "eventHandler.pyc", line 96, in __init__
File "eventHandler.pyc", line 112, in next
File "extensionPoints\util.pyc", line 169, in callWithSupportedKwargs
File "inspect.pyc", line 3015, in bind
File "inspect.pyc", line 2956, in _bind
TypeError: multiple values for argument 'ch'
***
Why? event_typedCharacter definition should be ok, according to other occurrences in NVDA sourcecode...
Alberto


James Scholes
 

Rather than binding the method to your app module, have you tried adding it to a custom overlay class for the tree view item? I took a brief look at event_typedCharacter usage in the NVDA codebase, and it seemed to be bound to an object, not a plug-in. It seems unlikely that you want to intercept all typed characters throughout the entire application...

Alternatively, how about:

def event_typedCharacter(self, *args, **kwargs):
ch = kwargs.get('ch', '')
if ch:
# something

You could also use such a signature to log all args and kwargs to fix the error.

Regards,

James Scholes

On 07/11/2020 at 8:40 am, Alberto Buffolino wrote:
Hi all,
I'm working on an appModule for an Eclipse/Java-based application
(RSSOwlnix, specifically).
In AppModule class, I have this method:
***
def event_typedCharacter(self, ch):
obj = api.getFocusObject()
if obj.role == ct.ROLE_TREEVIEWITEM:
ui.message("set as read/unread")
obj.setFocus()
***
it should force a gainFocus event on current treeview item, but the
problem is that, when I press "m" over the treeview item in the
application, I get this error:
***
WARNING - eventHandler._EventExecuter.next (15:30:03.031) - MainThread
(12084):
Could not execute function event_typedCharacter defined in
appModules.rssowlnix module; kwargs: {'ch': 'm'}
Traceback (most recent call last):
File "eventHandler.pyc", line 105, in next
TypeError: event_typedCharacter() got multiple values for argument 'ch'
ERROR - eventHandler.executeEvent (15:30:03.032) - MainThread (12084):
error executing event: typedCharacter on
<NVDAObjects.Dynamic_TreeViewItemOutlineItemIAccessible object at
0x07D0E390> with extra args of {'ch': 'm'}
Traceback (most recent call last):
File "eventHandler.pyc", line 246, in executeEvent
File "eventHandler.pyc", line 96, in __init__
File "eventHandler.pyc", line 112, in next
File "extensionPoints\util.pyc", line 169, in callWithSupportedKwargs
File "inspect.pyc", line 3015, in bind
File "inspect.pyc", line 2956, in _bind
TypeError: multiple values for argument 'ch'
***
Why? event_typedCharacter definition should be ok, according to other
occurrences in NVDA sourcecode...
Alberto





Alberto Buffolino
 

James Scholes, il 07/11/2020 20.55, ha scritto:
Rather than binding the method to your app module, have you tried adding it to a custom overlay class for the tree view item?
Alberto:
Hi James,
yes, I solved in this way, with a event_typedCharacter(self), in an overlay class.
This is the result:
https://raw.githubusercontent.com/ABuffEr/rssowlnixSupport/master/addon/appModules/rssowlnix.py
Thanks for support.
Alberto