mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
[win] Insert emojis with Windows key + . (period) correctly
This commit is contained in:
parent
a6d9e5243f
commit
5ad969466b
@ -584,7 +584,9 @@ int Entry::getCaretFromMouse(MouseMessage* mousemsg)
|
||||
return std::clamp(i, 0, lastPos);
|
||||
}
|
||||
|
||||
void Entry::executeCmd(EntryCmd cmd, int unicodeChar, bool shift_pressed)
|
||||
void Entry::executeCmd(const EntryCmd cmd,
|
||||
const base::codepoint_t unicodeChar,
|
||||
const bool shift_pressed)
|
||||
{
|
||||
std::string text = this->text();
|
||||
const Range range = selectedRange();
|
||||
@ -615,11 +617,10 @@ void Entry::executeCmd(EntryCmd cmd, int unicodeChar, bool shift_pressed)
|
||||
if (lastCaretPos() < m_maxsize) {
|
||||
ASSERT(m_caret <= lastCaretPos());
|
||||
|
||||
std::wstring unicodeStr;
|
||||
unicodeStr.push_back(unicodeChar);
|
||||
const std::string unicodeStr =
|
||||
base::codepoint_to_utf8(unicodeChar);
|
||||
|
||||
text.insert(m_boxes[m_caret].from,
|
||||
base::to_utf8(unicodeStr));
|
||||
text.insert(m_boxes[m_caret].from, unicodeStr);
|
||||
recalcCharBoxes(text);
|
||||
++m_caret;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -9,6 +9,7 @@
|
||||
#define UI_ENTRY_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "base/codepoint.h"
|
||||
#include "obs/signal.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
@ -99,7 +100,7 @@ namespace ui {
|
||||
};
|
||||
|
||||
int getCaretFromMouse(MouseMessage* mousemsg);
|
||||
void executeCmd(EntryCmd cmd, int ascii, bool shift_pressed);
|
||||
void executeCmd(EntryCmd cmd, base::codepoint_t unicodeChar, bool shift_pressed);
|
||||
void forwardWord();
|
||||
void backwardWord();
|
||||
Range wordRange(int pos);
|
||||
|
@ -56,10 +56,11 @@ void Message::removeRecipient(Widget* widget)
|
||||
m_recipient = nullptr;
|
||||
}
|
||||
|
||||
KeyMessage::KeyMessage(MessageType type,
|
||||
KeyScancode scancode,
|
||||
KeyModifiers modifiers,
|
||||
int unicodeChar, int repeat)
|
||||
KeyMessage::KeyMessage(const MessageType type,
|
||||
const KeyScancode scancode,
|
||||
const KeyModifiers modifiers,
|
||||
const base::codepoint_t unicodeChar,
|
||||
const int repeat)
|
||||
: Message(type, modifiers)
|
||||
, m_scancode(scancode)
|
||||
, m_unicodeChar(unicodeChar)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define UI_MESSAGE_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "base/codepoint.h"
|
||||
#include "base/paths.h"
|
||||
#include "gfx/point.h"
|
||||
#include "gfx/rect.h"
|
||||
@ -100,18 +101,18 @@ namespace ui {
|
||||
KeyMessage(MessageType type,
|
||||
KeyScancode scancode,
|
||||
KeyModifiers modifiers,
|
||||
int unicodeChar,
|
||||
base::codepoint_t unicodeChar,
|
||||
int repeat);
|
||||
|
||||
KeyScancode scancode() const { return m_scancode; }
|
||||
int unicodeChar() const { return m_unicodeChar; }
|
||||
base::codepoint_t unicodeChar() const { return m_unicodeChar; }
|
||||
int repeat() const { return m_repeat; }
|
||||
bool isDeadKey() const { return m_isDead; }
|
||||
void setDeadKey(bool state) { m_isDead = state; }
|
||||
|
||||
private:
|
||||
KeyScancode m_scancode;
|
||||
int m_unicodeChar;
|
||||
base::codepoint_t m_unicodeChar;
|
||||
int m_repeat; // repeat=0 means the first time the key is pressed
|
||||
bool m_isDead;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user