Skip to content

Commit 632afd4

Browse files
committed
No need to handle cursor if the button is disabled
1 parent 733572b commit 632afd4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

examples/buttons/main.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,10 @@ auto make_controls(view& view_)
279279
sprite mail_button = sprite{"mail_180x790.png", 158*button_scale, button_scale};
280280
sprite transpo_button = sprite{"transpo_180x632.png", 158*button_scale, button_scale};
281281

282+
// Note: When disabling a sprite button, the sprite must have a fifth
283+
// frame specifically for the disabled state.
282284
auto phase_disabled = toggle_button(phase_button);
283-
phase_disabled.enable(false); // Note: When disabling a sprite button, the
284-
// sprite must have a fifth frame
285-
// specifically for the disabled
286-
// state.
285+
phase_disabled.enable(false);
287286

288287
auto sprite_buttons =
289288
group("Sprite Buttons",

lib/src/element/button.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace cycfi::elements
4545

4646
bool basic_button::cursor(context const& ctx, point /* p */, cursor_tracking status)
4747
{
48+
if (!is_enabled())
49+
return false;
4850
bool is_leaving = status != cursor_tracking::leaving;
4951
if (_state.hilite != is_leaving)
5052
hilite(is_leaving);

0 commit comments

Comments
 (0)