Skip to content

Commit

Permalink
Fixed the menu selection that was letting garbage
Browse files Browse the repository at this point in the history
This issue was introduced by the fix for another menu issue that was crashing
Wings3D when closing a window with the context menu active (commit: #be68730)

The fix redraw the entire menu unselected before it be displayed. It was also
needed to find for the window of the submenu item because it's not stored in
the object property of menudata.

NOTE: Fixed the menu selection that was letting garbage. Thanks to sciroccorics
  • Loading branch information
Micheus committed May 13, 2024
1 parent 996c469 commit bcfb405
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/wings_menu.erl
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ setup_dialog(Parent, Entries, Magnet, ScreenPos, Cache) ->
end,
MenuData;
#{frame := Frame} = MenuData ->
Entries0 = maps:get(entries, MenuData),
Col = maps:get(colors, MenuData),
menu_sel_cleanup(Col, Entries0),

Pos = fit_menu_on_display(Frame,ScreenPos),
wxWindow:move(Frame, Pos),
wxPopupTransientWindow:popup(Frame),
Expand Down Expand Up @@ -1131,6 +1135,24 @@ menu_item_desc(Desc, HotKey) ->
_ -> Desc ++ "\t" ++ HotKey
end.

menu_sel_cleanup(_, []) -> ok;
menu_sel_cleanup({BG,FG}=Col, [#menu{type=submenu, object=undefined, wxid=Id}|Menu]) ->
Panel = wxWindow:findWindowById(Id),
Set = fun() ->
setup_colors([Panel|wxWindow:getChildren(Panel)], BG, FG)
end,
wx:batch(Set),
menu_sel_cleanup(Col,Menu);
menu_sel_cleanup({BG,FG}=Col, [#menu{type=menu, object=Obj}|Menu]) ->
Panel = maps:get(panel, Obj),
Set = fun() ->
setup_colors(Panel, BG, FG)
end,
wx:batch(Set),
menu_sel_cleanup(Col,Menu);
menu_sel_cleanup(Col, [_|Menu]) ->
menu_sel_cleanup(Col,Menu).

%% We want to use the predefined id where they exist (mac) needs for it's
%% specialized menus but we want our shortcuts hmm.
%% We also get little predefined icons for OS's that have that.
Expand Down

0 comments on commit bcfb405

Please sign in to comment.