Merge pull request 'Small textbox fixes' (#41) from ilidemi/orca:textbox-fixes into main
Reviewed-on: #41
This commit is contained in:
commit
0d920670a2
14
src/ui/ui.c
14
src/ui/ui.c
|
@ -2663,10 +2663,6 @@ oc_ui_text_box_result oc_ui_text_box(const char* name, oc_arena* arena, oc_str8
|
|||
|
||||
oc_ui_sig sig = oc_ui_box_sig(frame);
|
||||
|
||||
if(sig.hovering)
|
||||
{
|
||||
oc_ui_box_set_hot(frame, true);
|
||||
|
||||
if(sig.pressed)
|
||||
{
|
||||
if(!oc_ui_box_active(frame))
|
||||
|
@ -2703,7 +2699,7 @@ oc_ui_text_box_result oc_ui_text_box(const char* name, oc_arena* arena, oc_str8
|
|||
}
|
||||
//NOTE: put cursor the closest to new cursor (this maximizes the resulting selection,
|
||||
// and seems to be the standard behaviour across a number of text editor)
|
||||
if(abs(newCursor - ui->editCursor) > abs(newCursor - ui->editMark))
|
||||
if(sig.pressed && abs(newCursor - ui->editCursor) > abs(newCursor - ui->editMark))
|
||||
{
|
||||
i32 tmp = ui->editCursor;
|
||||
ui->editCursor = ui->editMark;
|
||||
|
@ -2716,12 +2712,18 @@ oc_ui_text_box_result oc_ui_text_box(const char* name, oc_arena* arena, oc_str8
|
|||
ui->editMark = ui->editCursor;
|
||||
}
|
||||
}
|
||||
|
||||
if(sig.hovering)
|
||||
{
|
||||
oc_ui_box_set_hot(frame, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
oc_ui_box_set_hot(frame, false);
|
||||
|
||||
if(sig.pressed)
|
||||
if(oc_mouse_pressed(&ui->input, OC_MOUSE_LEFT) ||
|
||||
oc_mouse_pressed(&ui->input, OC_MOUSE_RIGHT) ||
|
||||
oc_mouse_pressed(&ui->input, OC_MOUSE_MIDDLE))
|
||||
{
|
||||
if(oc_ui_box_active(frame))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue