Added ctrl+a to select all text in a text-box

This commit is contained in:
ITR 2024-09-07 22:22:28 +02:00 committed by IntegratedQuantum
parent 1764de2912
commit df76d2da1b
3 changed files with 14 additions and 0 deletions

View File

@ -387,6 +387,14 @@ pub fn inputCharacter(self: *TextInput, character: u21) void {
}
}
pub fn selectAll(self: *TextInput, mods: main.Window.Key.Modifiers) void {
if(mods.control) {
self.selectionStart = 0;
self.cursor = @intCast(self.currentString.items.len);
self.ensureCursorVisibility();
}
}
pub fn copy(self: *TextInput, mods: main.Window.Key.Modifiers) void {
if(mods.control) {
if(self.cursor) |cursor| {

View File

@ -425,6 +425,11 @@ pub const textCallbacks = struct {
current.deleteRight(mods);
}
}
pub fn selectAll(mods: main.Window.Key.Modifiers) void {
if(selectedTextInput) |current| {
current.selectAll(mods);
}
}
pub fn copy(mods: main.Window.Key.Modifiers) void {
if(selectedTextInput) |current| {
current.copy(mods);

View File

@ -335,6 +335,7 @@ pub const KeyBoard = struct { // MARK: KeyBoard
.{.name = "textGotoEnd", .key = c.GLFW_KEY_END, .repeatAction = &gui.textCallbacks.gotoEnd},
.{.name = "textDeleteLeft", .key = c.GLFW_KEY_BACKSPACE, .repeatAction = &gui.textCallbacks.deleteLeft},
.{.name = "textDeleteRight", .key = c.GLFW_KEY_DELETE, .repeatAction = &gui.textCallbacks.deleteRight},
.{.name = "textSelectAll", .key = c.GLFW_KEY_A, .repeatAction = &gui.textCallbacks.selectAll},
.{.name = "textCopy", .key = c.GLFW_KEY_C, .repeatAction = &gui.textCallbacks.copy},
.{.name = "textPaste", .key = c.GLFW_KEY_V, .repeatAction = &gui.textCallbacks.paste},
.{.name = "textCut", .key = c.GLFW_KEY_X, .repeatAction = &gui.textCallbacks.cut},