Small textbox fixes
Lose focus on mouse click outside Update selection while dragging outside the box Stop trying to flip the selection on drag, keep shift+click
This commit is contained in:
parent
e0db03b51c
commit
40887a9a2d
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);
|
oc_ui_sig sig = oc_ui_box_sig(frame);
|
||||||
|
|
||||||
if(sig.hovering)
|
|
||||||
{
|
|
||||||
oc_ui_box_set_hot(frame, true);
|
|
||||||
|
|
||||||
if(sig.pressed)
|
if(sig.pressed)
|
||||||
{
|
{
|
||||||
if(!oc_ui_box_active(frame))
|
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,
|
//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)
|
// 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;
|
i32 tmp = ui->editCursor;
|
||||||
ui->editCursor = ui->editMark;
|
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;
|
ui->editMark = ui->editCursor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(sig.hovering)
|
||||||
|
{
|
||||||
|
oc_ui_box_set_hot(frame, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oc_ui_box_set_hot(frame, false);
|
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))
|
if(oc_ui_box_active(frame))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue