MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / onProcessMessage

Method onProcessMessage

src/ui/int_entry.cpp:67–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67bool IntEntry::onProcessMessage(Message* msg)
68{
69 switch (msg->type()) {
70
71 // Reset value if it's out of bounds when focus is lost
72 case kFocusLeaveMessage:
73 setValue(MID(m_min, getValue(), m_max));
74 deselectText();
75 break;
76
77 case kMouseDownMessage:
78 requestFocus();
79 captureMouse();
80
81 openPopup();
82 selectAllText();
83 return true;
84
85 case kMouseMoveMessage:
86 if (hasCapture()) {
87 MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
88 Widget* pick = manager()->pick(mouseMsg->position());
89 if (pick == &m_slider) {
90 releaseMouse();
91
92 MouseMessage mouseMsg2(kMouseDownMessage,
93 mouseMsg->pointerType(),
94 mouseMsg->buttons(),
95 mouseMsg->modifiers(),
96 mouseMsg->position());
97 m_slider.sendMessage(&mouseMsg2);
98 }
99 }
100 break;
101
102 case kMouseWheelMessage:
103 if (isEnabled()) {
104 int oldValue = getValue();
105 int newValue = oldValue
106 + static_cast<MouseMessage*>(msg)->wheelDelta().x
107 - static_cast<MouseMessage*>(msg)->wheelDelta().y;
108 newValue = MID(m_min, newValue, m_max);
109 if (newValue != oldValue) {
110 setValue(newValue);
111 selectAllText();
112 }
113 return true;
114 }
115 break;
116
117 case kKeyDownMessage:
118 if (hasFocus() && !isReadOnly()) {
119 KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
120 int chr = keymsg->unicodeChar();
121 if (chr < '0' || chr > '9') {
122 // By-pass Entry::onProcessMessage()
123 return Widget::onProcessMessage(msg);
124 }

Callers

nothing calls this directly

Calls 9

pickMethod · 0.80
buttonsMethod · 0.80
sendMessageMethod · 0.80
typeMethod · 0.45
positionMethod · 0.45
pointerTypeMethod · 0.45
modifiersMethod · 0.45
wheelDeltaMethod · 0.45
unicodeCharMethod · 0.45

Tested by

no test coverage detected