Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

[FIXED] Error re-opening configuration of mouse MoveRelative

Found a bug in EventGhost? Report it here.
Post Reply
magao
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

[FIXED] Error re-opening configuration of mouse MoveRelative

Post by magao »

EventGhost 0.3.6.1484, Windows XP SP3

Once the Move Relative (Change Mouse Position) action has created, it is not possible to re-open the configuration for it, getting the exception:

Code: Select all

Error while configuring: Change Mouse position by x:None, y:-100
Traceback (most recent call last):
  File "C:\Program Files\EventGhost\eg\Classes\MainFrame\TreeCtrl.py", line 305, in OnLeftDoubleClick
    eg.UndoHandler.Configure().Try(self.document)
  File "C:\Program Files\EventGhost\eg\Classes\UndoHandler\Configure.py", line 29, in Try
    eg.Greenlet(self.Do).switch(item)
  File "C:\Program Files\EventGhost\eg\Classes\UndoHandler\Configure.py", line 54, in Do
    newArgs = gr.switch(*item.GetArgs())
  File "C:\Program Files\EventGhost\plugins\Mouse\__init__.py", line 401, in Configure
    xCtrl.Enable(False)
UnboundLocalError: local variable 'xCtrl' referenced before assignment
The problem is this code (plugins/Mouse/__init__.py, lines 399-412):

Code: Select all

if x is None:
    x = 0
    xCtrl.Enable(False)
xCtrl = panel.SpinIntCtrl(x, min=-maxint-1, max=maxint)

yCB = panel.CheckBox(y is not None, text.text3)
def HandleYCheckBox(event):
    yCtrl.Enable(event.IsChecked())  
yCB.Bind(wx.EVT_CHECKBOX, HandleYCheckBox)    

if y is None:
    y = 0
    yCtrl.Enable(False)
yCtrl = panel.SpinIntCtrl(y, min=-maxint-1, max=maxint)
which needs to be changed to:

Code: Select all

xCtrl = panel.SpinIntCtrl(x, min=-maxint-1, max=maxint)
if x is None:
    x = 0
    xCtrl.Enable(False)

yCB = panel.CheckBox(y is not None, text.text3)
def HandleYCheckBox(event):
    yCtrl.Enable(event.IsChecked())  
yCB.Bind(wx.EVT_CHECKBOX, HandleYCheckBox)    

yCtrl = panel.SpinIntCtrl(y, min=-maxint-1, max=maxint)
if y is None:
    y = 0
    yCtrl.Enable(False)
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Error re-opening configuration of mouse Move Relative action

Post by jinxdone »

Hello.

The problem you described was caused by the 'None' value in your configuration. However as for the fix I went for this instead:

Code: Select all

        if x is None:
            x = 0
            xCtrl = panel.SpinIntCtrl(x, min=-maxint-1, max=maxint)
            xCtrl.Enable(False)
        else:
            xCtrl = panel.SpinIntCtrl(x, min=-maxint-1, max=maxint)
The bug was present in both move absolute and move relative actions in the config dialog's x and y value handling when value is 'None'. You can get the fixed __init__.py from the svn or just wait for the next beta build.


Thanks for bringing this issue up. :)

-jinxdone
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Error re-opening configuration of mouse Move Relative action

Post by Bitmonster »

Funny no one has noticed this before, as the code hasn't been changed for a pretty long time. I incorporated a fix in some other way as jinxdone wrote, as I didn't saw he has committed his change and I also changed some other minor things, so I preferred to simple overwrite his commit.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: [FIXED] Error re-opening configuration of mouse MoveRelative

Post by jinxdone »

I would assume people usually leave the settings to '0' rather than 'None', so maybe that's why it hasn't been noticed earlier.. Also looking at the diff to your patch I see you did basically the same thing but in a more python-like manner compared to mine. :)
Post Reply