Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Use id instead of pos to robustly locate VisualToolDrag button
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqr committed May 7, 2020
1 parent 0623f4f commit bee19bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/visual_tool_drag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ VisualToolDrag::VisualToolDrag(VideoDisplay *parent, agi::Context *context)
void VisualToolDrag::SetToolbar(wxToolBar *tb) {
toolbar = tb;
toolbar->AddSeparator();
toolbar->AddTool(-1, _("Toggle between \\move and \\pos"), ICON(visual_move_conv_move));
move_pos_button = toolbar->AddTool(-1, _("Toggle between \\move and \\pos"), ICON(visual_move_conv_move))->GetId();
toolbar->Realize();
toolbar->Show(true);

Expand All @@ -76,8 +76,7 @@ void VisualToolDrag::UpdateToggleButtons() {

if (to_move == button_is_move) return;

toolbar->SetToolNormalBitmap(toolbar->GetToolByPos(1)->GetId(),
to_move ? ICON(visual_move_conv_move) : ICON(visual_move_conv_pos));
toolbar->SetToolNormalBitmap(move_pos_button, to_move ? ICON(visual_move_conv_move) : ICON(visual_move_conv_pos));
button_is_move = to_move;
}

Expand Down
1 change: 1 addition & 0 deletions src/visual_tool_drag.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class wxToolBar;
class VisualToolDrag final : public VisualTool<VisualToolDragDraggableFeature> {
/// The subtoolbar for the move/pos conversion button
wxToolBar *toolbar;
int move_pos_button;
/// The feature last clicked on for the double-click handler
/// Equal to curFeature during drags; possibly different at all other times
/// nullptr if no features have been clicked on or the last clicked on one no
Expand Down

0 comments on commit bee19bf

Please sign in to comment.