mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 23:11:49 +00:00
add switching text edit state
This commit is contained in:
parent
968d01274a
commit
726f004893
4 changed files with 19 additions and 3 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "Container.hpp"
|
#include "Container.hpp"
|
||||||
#include "graphics/core/Batch2D.hpp"
|
#include "graphics/core/Batch2D.hpp"
|
||||||
|
#include "graphics/ui/GUI.hpp"
|
||||||
|
|
||||||
using gui::UINode;
|
using gui::UINode;
|
||||||
using gui::Align;
|
using gui::Align;
|
||||||
|
|
@ -107,11 +108,13 @@ bool UINode::isPressed() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UINode::onFocus() {
|
void UINode::onFocus() {
|
||||||
|
gui.getInput().startTextInput();
|
||||||
focused = true;
|
focused = true;
|
||||||
focusCallbacks.notify(gui);
|
focusCallbacks.notify(gui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UINode::defocus() {
|
void UINode::defocus() {
|
||||||
|
gui.getInput().stopTextInput();
|
||||||
focused = false;
|
focused = false;
|
||||||
defocusCallbacks.notify(gui);
|
defocusCallbacks.notify(gui);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,6 @@ Mousecode input_util::mousecode_from(const std::string& name) {
|
||||||
|
|
||||||
SDLInput::SDLInput(SDLWindow& window) : window(window) {
|
SDLInput::SDLInput(SDLWindow& window) : window(window) {
|
||||||
input_util::initialize();
|
input_util::initialize();
|
||||||
// We should always get char stream (maybe)
|
|
||||||
SDL_StartTextInput(window.getSdlWindow());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLInput::pollEvents() {
|
void SDLInput::pollEvents() {
|
||||||
|
|
@ -234,6 +232,15 @@ void SDLInput::setClipboardText(const char* text) {
|
||||||
SDL_SetClipboardText(text);
|
SDL_SetClipboardText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLInput::startTextInput() {
|
||||||
|
logger.debug() << "Start text input";
|
||||||
|
SDL_StartTextInput(window.getSdlWindow());
|
||||||
|
}
|
||||||
|
void SDLInput::stopTextInput() {
|
||||||
|
logger.debug() << "Stop text input";
|
||||||
|
SDL_StopTextInput(window.getSdlWindow());
|
||||||
|
}
|
||||||
|
|
||||||
int SDLInput::getScroll() {
|
int SDLInput::getScroll() {
|
||||||
return scroll;
|
return scroll;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include <SDL3/SDL_keycode.h>
|
#include <SDL3/SDL_keycode.h>
|
||||||
|
|
||||||
#include "window/input.hpp"
|
|
||||||
#include "window/Window.hpp"
|
#include "window/Window.hpp"
|
||||||
|
#include "window/input.hpp"
|
||||||
|
|
||||||
class SDLWindow;
|
class SDLWindow;
|
||||||
|
|
||||||
|
|
@ -18,6 +18,9 @@ public:
|
||||||
const char* getClipboardText() const override;
|
const char* getClipboardText() const override;
|
||||||
void setClipboardText(const char* str) override;
|
void setClipboardText(const char* str) override;
|
||||||
|
|
||||||
|
void startTextInput() override;
|
||||||
|
void stopTextInput() override;
|
||||||
|
|
||||||
int getScroll() override;
|
int getScroll() override;
|
||||||
|
|
||||||
bool pressed(Keycode keycode) const override;
|
bool pressed(Keycode keycode) const override;
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,9 @@ public:
|
||||||
virtual const char* getClipboardText() const = 0;
|
virtual const char* getClipboardText() const = 0;
|
||||||
virtual void setClipboardText(const char* str) = 0;
|
virtual void setClipboardText(const char* str) = 0;
|
||||||
|
|
||||||
|
virtual void startTextInput() = 0;
|
||||||
|
virtual void stopTextInput() = 0;
|
||||||
|
|
||||||
virtual int getScroll() = 0;
|
virtual int getScroll() = 0;
|
||||||
|
|
||||||
virtual bool pressed(Keycode keycode) const = 0;
|
virtual bool pressed(Keycode keycode) const = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue