Wings 3D Development Forum

Full Version: [fixed] Why CTRL+R not equal to MMB ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What's going on ?



If it is a BUG ... then we can move to BUGS ... and I can try to fix. If not ... and I'm doing something silly ... please let me know about that.
My Wings3d 2.0.1:
[Image: body-flip_zps453b5627.png]
Everything seems to be OK.
OK, you are using the settings for mouse with TWO buttons only.
You could have said that. Undecided

Yeah, CTRL + Right click is not acting as it should (MMB)
I had a good run around in code looking for the spot to even start setting "TRAP" to find bug. No luck yet. Please move to BUGS and I will look more to try and find the bug, and then to git-hub thing.
This is seems like a fix ...
Code:
get_mouse_state() ->
    wx:batch(fun() ->
             MS = wx_misc:getMouseState(),
             #wxMouseState{x=X0, y=Y0,  %% integer()
                   leftDown=Left,
                   middleDown=Middle,
                   rightDown=Right %% bool()
                  } = MS,
             {X,Y} = wxWindow:screenToClient(get(gl_canvas), {X0,Y0}),

             C = wings_io:is_modkey_pressed(?CTRL_BITS),
             if (C andalso Right) ->  % example ... used by Nendo two button folks.
                 {gui_state([{Left,   ?SDL_BUTTON_LMASK},
                     {true, ?SDL_BUTTON_MMASK},
                     {false,  ?SDL_BUTTON_RMASK}], 0), X, Y};
             true ->
                 {gui_state([{Left,   ?SDL_BUTTON_LMASK},
                     {Middle, ?SDL_BUTTON_MMASK},
                     {Right,  ?SDL_BUTTON_RMASK}], 0), X, Y}
             end
         end).
ggaliens, it will not work since only the coordinate returned by this function is used by wings_menu module (called in two places).

I took a look on it and it needs to be managed in the popup_events handler. There, the second bind option for receive will process the mouse button for the item selected and it's processing only the three buttons returned in the #wxMouse{type=What} => What -> left_up,middle_up and right_up.

As I believe it should to process the mouse buttons as in the preferences, we need to check for num_buttons value and handle the translations to One and Two buttons (not only Two).

The workaround/fix I did works fine, but we can get a side effect when using One button: Alt+click in Flip command is intend to duplicate the object before flip it. Smile

Here is the code from wings_menu.erl in case you want to evaluate it. The changes/adds are signed with [*** xxxx ***].

Code:
:
popup_events(Dialog, Panel, Entries, Magnet, Previous, Ns, Owner) ->
    receive
    #wx{id=Id, obj=Obj, event=#wxMouse{type=enter_window}} ->
        Set = fun() ->
:
    #wx{id=Id0, event=Ev=#wxMouse{type=_What, y=Y, x=X}} ->     [*** changes here ***]
        Id = case Id0 > 0 orelse find_active_panel(Panel, X, Y) of
             true -> Id0;
             {false, _} = No -> No;
             {AId, _} -> AId
         end,
            What = mouse_button(Ev),     [*** That is new ***]
        case Id of
        {false, outside} when What =:= right_up ->
            wxPopupTransientWindow:dismiss(Dialog),
            wings_wm:psend(Owner, restart_menu);
        {false, _} ->
:
        end;
    #wx{event=#wxShow{}} ->
:
    end.
:
:
mouse_index(left_up) -> 1;
mouse_index(middle_up) -> 2;
mouse_index(right_up) -> 3.

[*** That is new ***]
mouse_button(#wxMouse{type=What, controlDown = Ctrl, altDown = Alt, metaDown = Meta}) ->
        case wings_pref:get_value(num_buttons) of
            1 ->
                case {What,Alt,Ctrl} of
                    {left_up,true,false} -> middle_up;
                    {left_up,false,true} -> right_up;
                    _ -> What
                end;
            2 ->
                case {What,(Ctrl or Meta)} of
                    {right_up,true} -> middle_up;
                    _ -> What
                end;
            _ -> What
        end.
What Macs still have 1 button ?

Aren't those macs very old ?

If you think your fix is sound/good Micheus ... please let Dan look at it (pull request).
(10-30-2015, 02:27 PM)ggaliens Wrote: [ -> ]What Macs still have 1 button ?
Aren't those macs very old ?
Who knows if someone still could be using one? Smile

Quote:please let Dan look at it (pull request).
As I already have the code changed I will do that. Did you try it?!