Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxGUI/digitizer: fix digitizer - VDigitToolbar.OnTool method was not called #3027

Merged
merged 4 commits into from Jun 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions gui/wxpython/vdigit/toolbars.py
Expand Up @@ -54,6 +54,9 @@ def __init__(self, parent, toolSwitcher, MapWindow, digitClass, giface, tools=[]
self.editingStopped.connect(layerTree.StopEditing)
self.editingBgMap.connect(layerTree.SetBgMapForEditing)

# replace OnTool from controller
self.controller.OnTool = self.OnTool

# bind events
self.Bind(wx.EVT_SHOW, self.OnShow)

Expand Down Expand Up @@ -446,14 +449,15 @@ def OnTool(self, event):
3,
f"VDigitToolbar.OnTool(): id = {event.GetId() if event else event}",
)
if self.toolSwitcher:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you try activate Digitize new boundary (Ctrl+B) or Digitize new centroid (Ctrl+C) tool by keyboard shortcut you get error:

Traceback (most recent call last):
  File
"/usr/lib64/grass84/gui/wxpython/vdigit/mapwindow.py", line
220, in OnKeyDown

event = self.toolbar.OnTool(tool["event"])
  File "/usr/lib64/grass84/gui/wxpython/vdigit/toolbars.py",
line 453, in OnTool

self.toolSwitcher.ToolChanged(event.GetId())
AttributeError
:
'NoneType' object has no attribute 'GetId'

code line should be:

if self.toolSwitcher and event:

self.toolSwitcher.ToolChanged(event.GetId())

# set cursor
self.MapWindow.SetNamedCursor("cross")
self.MapWindow.mouse["box"] = "point"
self.MapWindow.mouse["use"] = "pointer"

aId = self.action.get("id", -1)
if event:
BaseToolbar.OnTool(self, event)

# clear tmp canvas
if self.action["id"] != aId or aId == -1:
Expand All @@ -467,8 +471,7 @@ def OnTool(self, event):
if self.action["id"] == -1:
self.action = {"desc": "", "type": "", "id": -1}

# set focus
self.MapWindow.SetFocus()
event.Skip()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment.

code line should be:

if event:
    event.Skip()


def OnAddPoint(self, event):
"""Add point to the vector map Laier"""
Expand Down