diff options
Diffstat (limited to 'src/ui_elements')
| -rw-r--r-- | src/ui_elements/Button.c | 5 | ||||
| -rw-r--r-- | src/ui_elements/UI.h | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/ui_elements/Button.c b/src/ui_elements/Button.c index f3ab8fa..e7293c8 100644 --- a/src/ui_elements/Button.c +++ b/src/ui_elements/Button.c @@ -1,8 +1,8 @@ #include "UI.h" #include <raylib.h> -void UpdateButton(Button *btn, Rectangle *location) { - if (IsMouseInRec(*location) && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { +void UpdateButton(Button *btn) { + if (IsMouseInRec(btn->previousFramePosition) && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { btn->OnClick(btn->parent); } } @@ -14,4 +14,5 @@ void DrawButton(Button *btn, Rectangle *location) { (Vector2) { 0 , 0 }, 0, WHITE); + btn->previousFramePosition = *location; } diff --git a/src/ui_elements/UI.h b/src/ui_elements/UI.h index c23faf7..532dd68 100644 --- a/src/ui_elements/UI.h +++ b/src/ui_elements/UI.h @@ -25,9 +25,10 @@ typedef struct { void (*OnClick)(Scene *); Texture *atlas; Rectangle textrueLocation; + Rectangle previousFramePosition; } Button; -void UpdateButton(Button *btn, Rectangle *location); +void UpdateButton(Button *btn); void DrawButton(Button *btn, Rectangle *location); // ========== TEXT EDITOR ========== |
