Ticket #1028: #1028.patch

File #1028.patch, 4.5 KB (added by gerbilOFdoom, 12 years ago)

Patch to add right-click functionality

  • binaries/data/mods/public/gui/session/input.js

     
    11471147}
    11481148
    11491149// Called by unit selection buttons
    1150 function changePrimarySelectionGroup(templateName)
     1150function changePrimarySelectionGroup(templateName, rightPressed)
    11511151{
    1152     if (Engine.HotkeyIsPressed("session.deselectgroup"))
     1152   
     1153    if (Engine.HotkeyIsPressed("session.deselectgroup") || rightPressed)
    11531154        g_Selection.makePrimarySelection(templateName, true);
    11541155    else
    11551156        g_Selection.makePrimarySelection(templateName, false);
  • binaries/data/mods/public/gui/session/unit_commands.js

     
    295295        button.tooltip = tooltip;
    296296
    297297        // Button Function (need nested functions to get the closure right)
    298         button.onpress = (function(e){ return function() { callback(e) } })(item);
     298        if(guiName == "Selection")
     299            button.onpressright = (function(e){return function() {callback(e, true) } })(item);
     300        button.onpress = (function(e){ return function() {callback(e, false) } })(item);
    299301
    300302        // Get icon image
    301303        if (guiName == "Formation")
     
    473475
    474476        if (selection.length > 1)
    475477            setupUnitPanel("Selection", usedPanels, entState, g_Selection.groups.getTemplateNames(),
    476                 function (entType) { changePrimarySelectionGroup(entType); } );
     478                function (entType, rightPressed) { changePrimarySelectionGroup(entType, rightPressed); } );
    477479
    478480        var commands = getEntityCommandsList(entState);
    479481        if (commands.length)
  • source/gui/IGUIButtonBehavior.cpp

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
     
    3939    // TODO Gee: easier access functions
    4040    switch (Message.type)
    4141    {
     42    case GUIM_MOUSE_PRESS_RIGHT:
     43    {
     44        bool enabled;
     45        GUI<bool>::GetSetting(this, "enabled", enabled);
     46   
     47        if (!enabled)
     48            break;
     49
     50        m_PressedRight = true;
     51    }   break;
    4252    case GUIM_MOUSE_PRESS_LEFT:
    4353    {
    4454        bool enabled;
     
    4959
    5060        m_Pressed = true;
    5161    }   break;
     62    case GUIM_MOUSE_DBLCLICK_RIGHT:
     63    case GUIM_MOUSE_RELEASE_RIGHT:
     64    {
     65        bool enabled;
     66        GUI<bool>::GetSetting(this, "enabled", enabled);
     67   
     68        if (!enabled)
     69            break;
    5270
     71        if (m_PressedRight)
     72        {
     73            m_PressedRight = false;
     74            if (Message.type == GUIM_MOUSE_RELEASE_RIGHT)
     75            {
     76                // Button was right-clicked
     77                SendEvent(GUIM_PRESSED, "pressright");
     78            }
     79            else
     80            {
     81                // Button was clicked a second time. We can't tell if the button
     82                // expects to receive doublepress events or just a second press
     83                // event, so send both of them (and assume the extra unwanted press
     84                // is harmless on buttons that expect doublepress)
     85                SendEvent(GUIM_PRESSED, "pressright");
     86                SendEvent(GUIM_DOUBLE_PRESSED, "doublepressright");
     87            }
     88        }
     89    }   break;
    5390    case GUIM_MOUSE_DBLCLICK_LEFT:
    5491    case GUIM_MOUSE_RELEASE_LEFT:
    5592    {
  • source/gui/IGUIButtonBehavior.h

     
    114114    {
    115115        m_MouseHovering = false;
    116116        m_Pressed = false;
     117        m_PressedRight = false;
    117118    }
    118119
    119120    /**
     
    121122     * you have to first press the button, and then release it...
    122123     * in between those two steps you can actually leave the button
    123124     * area, as long as you release it within the button area... Anyway
    124      * this lets us know we are done with step one (clicking).
     125     * this lets us know we are done with step one (clicking). Or right clicking
    125126     */
    126127    bool                            m_Pressed;
     128    bool                            m_PressedRight;
    127129};
    128130
    129131#endif