mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 12:44:53 +00:00
New ui::FocusMessage with oldFocus/newFocus fields
This commit is contained in:
parent
73b23c3830
commit
1d9f14665f
@ -964,10 +964,13 @@ void Manager::setFocus(Widget* widget)
|
|||||||
&& !(widget->hasFlags(DECORATIVE))
|
&& !(widget->hasFlags(DECORATIVE))
|
||||||
&& someParentIsFocusStop(widget)))) {
|
&& someParentIsFocusStop(widget)))) {
|
||||||
Widget* commonAncestor = findLowestCommonAncestor(focus_widget, widget);
|
Widget* commonAncestor = findLowestCommonAncestor(focus_widget, widget);
|
||||||
|
Widget* oldFocus = focus_widget;
|
||||||
|
|
||||||
// Fetch the focus
|
// Fetch the focus
|
||||||
if (focus_widget && focus_widget != commonAncestor) {
|
if (focus_widget && focus_widget != commonAncestor) {
|
||||||
auto msg = new Message(kFocusLeaveMessage);
|
auto* msg = new FocusMessage(kFocusLeaveMessage,
|
||||||
|
oldFocus,
|
||||||
|
widget);
|
||||||
msg->setRecipient(focus_widget);
|
msg->setRecipient(focus_widget);
|
||||||
msg->setPropagateToParent(true);
|
msg->setPropagateToParent(true);
|
||||||
msg->setCommonAncestor(commonAncestor);
|
msg->setCommonAncestor(commonAncestor);
|
||||||
@ -984,7 +987,9 @@ void Manager::setFocus(Widget* widget)
|
|||||||
// Put the focus
|
// Put the focus
|
||||||
focus_widget = widget;
|
focus_widget = widget;
|
||||||
if (widget) {
|
if (widget) {
|
||||||
auto msg = new Message(kFocusEnterMessage);
|
auto* msg = new FocusMessage(kFocusEnterMessage,
|
||||||
|
oldFocus,
|
||||||
|
widget);
|
||||||
msg->setRecipient(widget);
|
msg->setRecipient(widget);
|
||||||
msg->setPropagateToParent(true);
|
msg->setPropagateToParent(true);
|
||||||
msg->setCommonAncestor(commonAncestor);
|
msg->setCommonAncestor(commonAncestor);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
// Copyright (C) 2018-2024 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
@ -96,6 +96,21 @@ namespace ui {
|
|||||||
std::function<void()> m_callback;
|
std::function<void()> m_callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FocusMessage : public Message {
|
||||||
|
public:
|
||||||
|
FocusMessage(MessageType type,
|
||||||
|
Widget* oldFocus,
|
||||||
|
Widget* newFocus)
|
||||||
|
: Message(type)
|
||||||
|
, m_oldFocus(oldFocus)
|
||||||
|
, m_newFocus(newFocus) { }
|
||||||
|
Widget* oldFocus() { return m_oldFocus; }
|
||||||
|
Widget* newFocus() { return m_newFocus; }
|
||||||
|
private:
|
||||||
|
Widget* m_oldFocus;
|
||||||
|
Widget* m_newFocus;
|
||||||
|
};
|
||||||
|
|
||||||
class KeyMessage : public Message {
|
class KeyMessage : public Message {
|
||||||
public:
|
public:
|
||||||
KeyMessage(MessageType type,
|
KeyMessage(MessageType type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user