mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
Added ctrl+a to select all text in a text-box
This commit is contained in:
parent
1764de2912
commit
df76d2da1b
@ -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| {
|
||||
|
@ -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);
|
||||
|
@ -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},
|
||||
|
Loading…
x
Reference in New Issue
Block a user