1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
end
end
else
end
end
else
else
end
end
end
end
return
end
-- Can't click disabled buttons
if controlData and not controlData . isValidOption then
return
end
return
end
-- For now only the LMB will be allowed to click radio buttons.
if buttonId == MOUSE_BUTTON_INDEX_LEFT then
-- Set all buttons in the group to unpressed, and unlocked.
-- If the button is disabled externally (maybe it isn't a valid option at this time)
-- then set it to unpressed, but disabled.
end
-- Set the clicked button to pressed and lock it down (so that it stays pressed.)
end
end
end
end
-- Remember the original handler so that its call can be forced.
self . m_buttons [ button ] = { originalHandler = originalHandler , isValidOption = true } -- newly added buttons always start as valid options for now.
-- This throws away return values from the original function, which is most likely ok in the case of a click handler.
end
end
end
end
end
-- This changes the enabled state of the entire radio group, but must still take into account
-- whether each button is a valid option...for example, enabling a radio group that has certain
-- invalid options must remember to keep those options disabled.
do
end
end
end
-- Allow external control over whether individual buttons are valid options
-- within the group. Invalid options will force those buttons to appear disabled.
if ( buttonData and ( isValidOption ~= buttonData . isValidOption ) ) then
buttonData . isValidOption = isValidOption
-- NOTE: This doesn't update the state of the clicked button, because that could
-- potentially call a click handler that shouldn't be called at this time, or cause
-- more data to need to be updated externally...it's a best practice to first figure
-- out which buttons need to be validOptions, and then allow the clicked button to change.
end
end
do
-- Restore the button to its correct state, as if it hadn't been added to the radio group
-- Since "valid option" is set externally, just use that to figure out the current enabled state.
-- Reset handler, it's ok if this is nil, it means there was no original handler
-- so there shouldn't be one now...
end
end
if ( buttonData and buttonData . isValidOption )
then
end
end
end
-- Just change the state of the button group to reflect the current state of the data;
-- this shouldn't actually call any click handlers.
-- Find the button that's actually the clicked button from backing data
do
break
end
end
-- Update the state of all the buttons and reassign the currently clicked button
do
end
end
end
-- key: button, value: buttonData
end
end |