mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
Fix issue 352: Context Bar Eats Hotkey Input
Avoid capturing keyboard focus in context bar widgets.
This commit is contained in:
parent
10ae3a9d28
commit
f107dd3cbc
@ -294,6 +294,10 @@ protected:
|
||||
settings->getToolSettings(currentTool)
|
||||
->setInkType((InkType)getSelectedItemIndex());
|
||||
}
|
||||
|
||||
void onCloseListBox() OVERRIDE {
|
||||
releaseFocus();
|
||||
}
|
||||
};
|
||||
|
||||
class ContextBar::InkOpacityField : public IntEntry
|
||||
@ -379,6 +383,10 @@ protected:
|
||||
->setRotationAlgorithm(static_cast<Item*>(getSelectedItem())->algo());
|
||||
}
|
||||
|
||||
void onCloseListBox() OVERRIDE {
|
||||
releaseFocus();
|
||||
}
|
||||
|
||||
private:
|
||||
class Item : public ListItem {
|
||||
public:
|
||||
@ -410,6 +418,9 @@ public:
|
||||
->setFreehandAlgorithm(isSelected() ?
|
||||
kPixelPerfectFreehandAlgorithm:
|
||||
kDefaultFreehandAlgorithm);
|
||||
|
||||
releaseFocus(
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -451,6 +462,8 @@ protected:
|
||||
CheckBox::onClick(ev);
|
||||
|
||||
UIContext::instance()->settings()->setGrabAlpha(isSelected());
|
||||
|
||||
releaseFocus();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -542,6 +542,8 @@ void ComboBox::closeListBox()
|
||||
|
||||
getManager()->removeMessageFilter(kMouseDownMessage, this);
|
||||
getManager()->setFocus(m_entry);
|
||||
|
||||
onCloseListBox();
|
||||
}
|
||||
}
|
||||
|
||||
@ -571,4 +573,9 @@ void ComboBox::onChange()
|
||||
Change();
|
||||
}
|
||||
|
||||
void ComboBox::onCloseListBox()
|
||||
{
|
||||
CloseListBox();
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
@ -83,12 +83,14 @@ namespace ui {
|
||||
|
||||
// Signals
|
||||
Signal0<void> Change;
|
||||
Signal0<void> CloseListBox;
|
||||
|
||||
protected:
|
||||
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||
void onResize(ResizeEvent& ev) OVERRIDE;
|
||||
void onPreferredSize(PreferredSizeEvent& ev) OVERRIDE;
|
||||
virtual void onChange();
|
||||
virtual void onCloseListBox();
|
||||
|
||||
private:
|
||||
void onButtonClick(Event& ev);
|
||||
|
@ -61,20 +61,19 @@ bool IntEntry::onProcessMessage(Message* msg)
|
||||
{
|
||||
switch (msg->type()) {
|
||||
|
||||
// When the mouse enter in this entry, it got the focus and the
|
||||
// text is automatically selected.
|
||||
case kMouseEnterMessage:
|
||||
requestFocus();
|
||||
break;
|
||||
|
||||
// Reset value if it's out of bounds when focus is lost
|
||||
case kFocusLeaveMessage:
|
||||
setValue(MID(m_min, getValue(), m_max));
|
||||
deselectText();
|
||||
break;
|
||||
|
||||
case kMouseDownMessage:
|
||||
requestFocus();
|
||||
captureMouse();
|
||||
|
||||
openPopup();
|
||||
break;
|
||||
selectAllText();
|
||||
return true;
|
||||
|
||||
case kMouseMoveMessage:
|
||||
if (hasCapture()) {
|
||||
@ -103,6 +102,17 @@ bool IntEntry::onProcessMessage(Message* msg)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case kKeyDownMessage:
|
||||
if (hasFocus() && !isReadOnly()) {
|
||||
KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
|
||||
int chr = keymsg->unicodeChar();
|
||||
if (chr < '0' || chr > '9') {
|
||||
// By-pass Entry::onProcessMessage()
|
||||
return Widget::onProcessMessage(msg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return Entry::onProcessMessage(msg);
|
||||
}
|
||||
@ -131,6 +141,7 @@ void IntEntry::openPopup()
|
||||
m_popupWindow->setAutoRemap(false);
|
||||
m_popupWindow->setBounds(rc);
|
||||
m_popupWindow->setBgColor(rgba(0, 0, 0, 0));
|
||||
m_popupWindow->Close.connect(&IntEntry::onPopupClose, this);
|
||||
|
||||
Region rgn(rc.createUnion(getBounds()));
|
||||
rgn.createUnion(rgn, Region(getBounds()));
|
||||
@ -160,4 +171,10 @@ void IntEntry::onChangeSlider()
|
||||
selectAllText();
|
||||
}
|
||||
|
||||
void IntEntry::onPopupClose(CloseEvent& ev)
|
||||
{
|
||||
deselectText();
|
||||
releaseFocus();
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
@ -11,11 +11,11 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
class CloseEvent;
|
||||
class PopupWindow;
|
||||
class Slider;
|
||||
|
||||
class IntEntry : public Entry
|
||||
{
|
||||
class IntEntry : public Entry {
|
||||
public:
|
||||
IntEntry(int min, int max);
|
||||
~IntEntry();
|
||||
@ -34,6 +34,7 @@ namespace ui {
|
||||
void openPopup();
|
||||
void closePopup();
|
||||
void onChangeSlider();
|
||||
void onPopupClose(CloseEvent& ev);
|
||||
|
||||
int m_min;
|
||||
int m_max;
|
||||
|
Loading…
x
Reference in New Issue
Block a user