19#include "AAbstractTypeable.h"
25template<aui::derived_from<AView> Super>
29 public std::conditional_t<aui::derived_from<Super, IFontView>, std::monostate, IFontView>
34 AObject::connect(mBlinkTimer->fired,
this, [&]() {
35 if (this->hasFocus() && mCursorBlinkCount < 60) {
36 mCursorBlinkVisible = !mCursorBlinkVisible;
37 mCursorBlinkCount += 1;
45 void onKeyDown(AInput::Key key)
override {
46 Super::onKeyDown(key);
47 AAbstractTypeable::handleKey(key);
48 if (key == AInput::Key::RETURN && !AInput::isKeyDown(AInput::LSHIFT) && !AInput::isKeyDown(AInput::RSHIFT)) {
49 emit this->actionButtonPressed;
53 void onKeyRepeat(AInput::Key key)
override {
54 Super::onKeyRepeat(key);
55 AAbstractTypeable::handleKey(key);
58 void onFocusLost()
override {
60 if (mTextChangedFlag) {
61 mTextChangedFlag =
false;
69 Super::onPointerPressed(event);
70 ACursorSelectable::handleMousePressed(event);
71 updateCursorBlinking();
75 Super::onPointerDoubleClicked(event);
76 ACursorSelectable::handleMouseDoubleClicked(event);
77 updateCursorBlinking();
81 Super::onPointerMove(pos, event);
82 ACursorSelectable::handleMouseMove(pos);
86 Super::onPointerReleased(event);
90 ACursorSelectable::handleMouseReleased(event);
94 bool wantsTouchscreenKeyboard()
override {
98 bool handlesNonMouseNavigation()
override {
102 void onFocusAcquired()
override {
103 Super::onFocusAcquired();
104 updateCursorBlinking();
107 void invalidateAllStyles()
override {
109 this->invalidateAllStylesFont();
110 Super::invalidateAllStyles();
113 bool isLButtonPressed()
override {
114 return this->isPressed();
117 void drawCursor(
IRenderer& renderer, glm::ivec2 position) {
118 if (!this->hasFocus()) {
121 drawCursorImpl(renderer, position, this->getFontStyle().size);
126 return composeContextMenuImpl();
129 void commitStyle()
override {
130 Super::commitStyle();
131 this->commitStyleFont();
134 int getVerticalAlignmentOffset() noexcept {
135 return (glm::max)(0, int(glm::ceil((Super::getContentHeight() - this->getFontStyle().size) / 2.0)));
138 void cursorSelectableRedraw()
override {
142 void onSelectionChanged()
override {
143 onCursorIndexChanged();
144 if (selectionChanged)
emit selectionChanged(selection());
148 void emitTextChanged(
const AString&
text)
override {
152 void emitTextChanging(
const AString&
text)
override {
156 void emitActionButtonPressed()
override {
157 emit actionButtonPressed;
160 void typeableInvalidateFont()
override {
161 this->invalidateFont();
Basic implementation of type shortcuts and selection for editable text fields.
Definition: AAbstractTypeableView.h:31
Base class for AAbstractTypeableView which is template class.
Definition: AAbstractTypeable.h:25
AOptional< AInput::Key > button() const noexcept
Definition: APointerIndex.h:56
Represents a Unicode character string.
Definition: AString.h:37
A std::vector with AUI extensions.
Definition: AVector.h:38
Base class for rendering.
Definition: IRenderer.h:149
#define emit
emits the specified signal in context of this object.
Definition: AObject.h:196
Pointing method move event.
Definition: APointerMoveEvent.h:21
Pointing method press event.
Definition: APointerPressedEvent.h:21
Pointing method press event.
Definition: APointerReleasedEvent.h:19
bool triggerClick
Whether the pointer release event triggers click event or not.
Definition: APointerReleasedEvent.h:33
APointerIndex pointerIndex
Which button of the pointing device is triggered the event (AInput::LBUTTON if not present) or finger...
Definition: APointerReleasedEvent.h:28