Focus bugfix
This commit is contained in:
parent
8dfa484cdc
commit
16d456a10f
2 changed files with 12 additions and 11 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import rl "raylib"
|
||||
import back "back"
|
||||
import ui ".."
|
||||
import "core:fmt"
|
||||
|
||||
|
|
@ -39,6 +40,9 @@ UiElementData_FloatInput :: struct {
|
|||
}
|
||||
|
||||
main :: proc() {
|
||||
back.register_segfault_handler()
|
||||
_register_illegal_instruction_handler()
|
||||
|
||||
rl.SetTraceLogLevel(.WARNING)
|
||||
rl.InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_CAPTION)
|
||||
defer rl.CloseWindow()
|
||||
|
|
@ -57,6 +61,7 @@ main :: proc() {
|
|||
button_margin_value_string_x := cstring(make([^]u8, INPUT_FLOAT_CHARACTERS))
|
||||
button_margin_value_string_y := cstring(make([^]u8, INPUT_FLOAT_CHARACTERS))
|
||||
element_focus_id := ui.element_id_invalid()
|
||||
debug_element_focus_id := ui.element_id_invalid()
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
ui.start(&ctx, origin = {0, 0}, size = {WINDOW_WIDTH, WINDOW_HEIGHT})
|
||||
|
|
@ -119,10 +124,10 @@ main :: proc() {
|
|||
debug_elements := ui.end()
|
||||
|
||||
if rl.IsKeyPressed(.TAB) {
|
||||
element_focus_id = ui.focus_next_element(element_focus_id, {.InputFloat})
|
||||
debug_element_focus_id = ui.focus_next_element(debug_element_focus_id, debug_elements, {.InputFloat})
|
||||
}
|
||||
|
||||
render_ui_elements(&ctx, &element_focus_id, debug_elements)
|
||||
render_ui_elements(&ctx, &debug_element_focus_id, debug_elements)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +156,7 @@ ui_input_float_2d :: proc(width, height: ui.Size_Percentage, config: ui.ElementC
|
|||
ui.same_line()
|
||||
|
||||
data = new(UiElementData_FloatInput, allocator)
|
||||
data^ = {value_string = value_string_x, value = &value.x}
|
||||
data^ = {value_string = value_string_y, value = &value.y}
|
||||
ui.element(.InputFloat, dimensions, {margin = config.margin}, data)
|
||||
ui.container_end()
|
||||
return container
|
||||
|
|
|
|||
12
ui.odin
12
ui.odin
|
|
@ -119,18 +119,14 @@ same_line :: proc() {
|
|||
ctx.same_line = true
|
||||
}
|
||||
|
||||
focus_next_element :: proc(id: ElementId, allowed_focus: bit_set[ElementType]) -> ElementId {
|
||||
focus_next_element :: proc(id: ElementId, elements: []Element, allowed_focus: bit_set[ElementType]) -> ElementId {
|
||||
if id == element_id_invalid() {
|
||||
return element_id_invalid()
|
||||
}
|
||||
element_index := int(id.element_index)
|
||||
if element_index + 1 >= len(ctx.elements) {
|
||||
return element_id_invalid()
|
||||
}
|
||||
element_index += 1
|
||||
for element_index < len(ctx.elements) {
|
||||
if ctx.elements[element_index].type in allowed_focus {
|
||||
return ctx.elements[element_index].id
|
||||
for element_index < len(elements) {
|
||||
if elements[element_index].type in allowed_focus {
|
||||
return elements[element_index].id
|
||||
}
|
||||
element_index += 1
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue