mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Fix nudge and textbox creation (#672)
* Fix nudge and textbox creation * Code review * Cleanup veriable names
This commit is contained in:
committed by
Keavon Chambers
parent
a02b7a4635
commit
0887e56533
@@ -114,13 +114,18 @@ impl MessageHandler<InputPreprocessorMessage, ()> for InputPreprocessorMessageHa
|
||||
}
|
||||
|
||||
impl InputPreprocessorMessageHandler {
|
||||
fn translate_mouse_event(&mut self, new_state: MouseState, allow_first_button_down: bool, responses: &mut VecDeque<Message>) {
|
||||
fn translate_mouse_event(&mut self, mut new_state: MouseState, allow_first_button_down: bool, responses: &mut VecDeque<Message>) {
|
||||
for (bit_flag, key) in [(MouseKeys::LEFT, Key::Lmb), (MouseKeys::RIGHT, Key::Rmb), (MouseKeys::MIDDLE, Key::Mmb)] {
|
||||
// Calculate the intersection between the two key states
|
||||
let old_down = self.mouse.mouse_keys & bit_flag == bit_flag;
|
||||
let new_down = new_state.mouse_keys & bit_flag == bit_flag;
|
||||
if !old_down && new_down && (allow_first_button_down || self.mouse.mouse_keys != MouseKeys::NONE) {
|
||||
responses.push_back(InputMapperMessage::KeyDown(key).into());
|
||||
if !old_down && new_down {
|
||||
if allow_first_button_down || self.mouse.mouse_keys != MouseKeys::NONE {
|
||||
responses.push_back(InputMapperMessage::KeyDown(key).into());
|
||||
} else {
|
||||
// Required to stop a keyup being emitted for a keydown outside canvas
|
||||
new_state.mouse_keys ^= bit_flag;
|
||||
}
|
||||
}
|
||||
if old_down && !new_down {
|
||||
responses.push_back(InputMapperMessage::KeyUp(key).into());
|
||||
|
||||
Reference in New Issue
Block a user