1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:27:35 +00:00

HexEditor: Use widget override cursors

This commit is contained in:
Andreas Kling 2020-09-11 14:37:30 +02:00
parent 5872cb398c
commit 8f5b92865d
2 changed files with 4 additions and 10 deletions

View file

@ -26,7 +26,6 @@
#include "HexEditor.h" #include "HexEditor.h"
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
#include <LibGfx/Palette.h>
#include <LibGUI/Action.h> #include <LibGUI/Action.h>
#include <LibGUI/Clipboard.h> #include <LibGUI/Clipboard.h>
#include <LibGUI/FontDatabase.h> #include <LibGUI/FontDatabase.h>
@ -35,6 +34,7 @@
#include <LibGUI/ScrollBar.h> #include <LibGUI/ScrollBar.h>
#include <LibGUI/TextEditor.h> #include <LibGUI/TextEditor.h>
#include <LibGUI/Window.h> #include <LibGUI/Window.h>
#include <LibGfx/Palette.h>
#include <ctype.h> #include <ctype.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
@ -274,12 +274,13 @@ void HexEditor::mousemove_event(GUI::MouseEvent& event)
auto text_end_x = text_start_x + (bytes_per_row() * character_width()); auto text_end_x = text_start_x + (bytes_per_row() * character_width());
auto text_end_y = text_start_y + 5 + (total_rows() * line_height()); auto text_end_y = text_start_y + 5 + (total_rows() * line_height());
window()->set_cursor(Gfx::StandardCursor::None);
if ((absolute_x >= hex_start_x && absolute_x <= hex_end_x if ((absolute_x >= hex_start_x && absolute_x <= hex_end_x
&& absolute_y >= hex_start_y && absolute_y <= hex_end_y) && absolute_y >= hex_start_y && absolute_y <= hex_end_y)
|| (absolute_x >= text_start_x && absolute_x <= text_end_x || (absolute_x >= text_start_x && absolute_x <= text_end_x
&& absolute_y >= text_start_y && absolute_y <= text_end_y)) { && absolute_y >= text_start_y && absolute_y <= text_end_y)) {
window()->set_cursor(Gfx::StandardCursor::IBeam); set_override_cursor(Gfx::StandardCursor::IBeam);
} else {
set_override_cursor(Gfx::StandardCursor::None);
} }
if (m_in_drag_select) { if (m_in_drag_select) {
@ -581,9 +582,3 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
} }
} }
} }
void HexEditor::leave_event(Core::Event&)
{
ASSERT(window());
window()->set_cursor(Gfx::StandardCursor::None);
}

View file

@ -75,7 +75,6 @@ protected:
virtual void mousemove_event(GUI::MouseEvent&) override; virtual void mousemove_event(GUI::MouseEvent&) override;
virtual void keydown_event(GUI::KeyEvent&) override; virtual void keydown_event(GUI::KeyEvent&) override;
virtual bool accepts_focus() const override { return true; } virtual bool accepts_focus() const override { return true; }
virtual void leave_event(Core::Event&) override;
private: private:
bool m_readonly { false }; bool m_readonly { false };