mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 05:42:32 +00:00
Add KeyAction::Left/RightMouseButton (it's quite experimental at the moment)
This commit is contained in:
parent
8716214718
commit
b96d615d6c
@ -38,6 +38,7 @@
|
|||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "ui/accelerator.h"
|
#include "ui/accelerator.h"
|
||||||
#include "ui/message.h"
|
#include "ui/message.h"
|
||||||
|
#include "ui/system.h"
|
||||||
#include "ui/view.h"
|
#include "ui/view.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
@ -109,6 +110,32 @@ public:
|
|||||||
return isKeyActionPressed(KeyAction::SubtractSelection);
|
return isKeyActionPressed(KeyAction::SubtractSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool onProcessMessage(Message* msg) override {
|
||||||
|
switch (msg->type()) {
|
||||||
|
|
||||||
|
case kKeyDownMessage:
|
||||||
|
case kKeyUpMessage:
|
||||||
|
if (static_cast<KeyMessage*>(msg)->repeat() == 0) {
|
||||||
|
Key* lmb = KeyboardShortcuts::instance()->action(KeyAction::LeftMouseButton);
|
||||||
|
Key* rmb = KeyboardShortcuts::instance()->action(KeyAction::RightMouseButton);
|
||||||
|
|
||||||
|
// Convert action keys into mouse messages.
|
||||||
|
if (lmb->isPressed(msg) || rmb->isPressed(msg)) {
|
||||||
|
MouseMessage mouseMsg(
|
||||||
|
(msg->type() == kKeyDownMessage ? kMouseDownMessage: kMouseUpMessage),
|
||||||
|
(lmb->isPressed(msg) ? kButtonLeft: kButtonRight),
|
||||||
|
gfx::Point(jmouse_x(0), jmouse_y(0)));
|
||||||
|
|
||||||
|
sendMessage(&mouseMsg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return Editor::onProcessMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isKeyActionPressed(KeyAction action) {
|
bool isKeyActionPressed(KeyAction action) {
|
||||||
if (Key* key = KeyboardShortcuts::instance()->action(action))
|
if (Key* key = KeyboardShortcuts::instance()->action(action))
|
||||||
|
@ -57,6 +57,8 @@ namespace {
|
|||||||
{ "LockAxis" , "Lock Axis" , app::KeyAction::LockAxis },
|
{ "LockAxis" , "Lock Axis" , app::KeyAction::LockAxis },
|
||||||
{ "AddSelection" , "Add Selection" , app::KeyAction::AddSelection },
|
{ "AddSelection" , "Add Selection" , app::KeyAction::AddSelection },
|
||||||
{ "SubtractSelection" , "Subtract Selection" , app::KeyAction::SubtractSelection },
|
{ "SubtractSelection" , "Subtract Selection" , app::KeyAction::SubtractSelection },
|
||||||
|
{ "LeftMouseButton" , "Trigger Left Mouse Button" , app::KeyAction::LeftMouseButton },
|
||||||
|
{ "RightMouseButton" , "Trigger Right Mouse Button" , app::KeyAction::RightMouseButton },
|
||||||
{ NULL , NULL , app::KeyAction::None }
|
{ NULL , NULL , app::KeyAction::None }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,6 +67,8 @@ namespace app {
|
|||||||
LockAxis,
|
LockAxis,
|
||||||
AddSelection,
|
AddSelection,
|
||||||
SubtractSelection,
|
SubtractSelection,
|
||||||
|
LeftMouseButton,
|
||||||
|
RightMouseButton
|
||||||
};
|
};
|
||||||
|
|
||||||
class Key {
|
class Key {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user