LinkLabel.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2020, Alex McGrath <amk@amk.ie>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGUI/Label.h>
  8. namespace GUI {
  9. class LinkLabel : public Label {
  10. C_OBJECT_ABSTRACT(LinkLabel);
  11. public:
  12. static ErrorOr<NonnullRefPtr<LinkLabel>> try_create(String text = {});
  13. Function<void()> on_click;
  14. private:
  15. explicit LinkLabel(String text = {});
  16. ErrorOr<void> create_actions();
  17. ErrorOr<void> create_menus();
  18. virtual void mousemove_event(MouseEvent&) override;
  19. virtual void mousedown_event(MouseEvent&) override;
  20. virtual void paint_event(PaintEvent&) override;
  21. virtual void resize_event(ResizeEvent&) override;
  22. virtual void leave_event(Core::Event&) override;
  23. virtual void keydown_event(KeyEvent&) override;
  24. virtual void context_menu_event(ContextMenuEvent&) override;
  25. virtual void did_change_text() override;
  26. void update_tooltip_if_needed();
  27. void set_hovered(bool);
  28. RefPtr<Menu> m_context_menu;
  29. RefPtr<Action> m_open_action;
  30. RefPtr<Action> m_copy_action;
  31. bool m_hovered { false };
  32. };
  33. }