entry: add text selection abilities. gtk3 part

This commit is contained in:
Rustam Gamidov 2020-04-09 09:03:55 +03:00
parent 9c391068d7
commit 0a2cfd1238
No known key found for this signature in database
GPG Key ID: 093B162FB3DE6996
1 changed files with 14 additions and 0 deletions

View File

@ -57,6 +57,20 @@ void uiEntrySetText(uiEntry *e, const char *text)
// don't queue the control for resize; entry sizes are independent of their contents // don't queue the control for resize; entry sizes are independent of their contents
} }
void uiEntrySelectText(uiEntry *e, int start, int end)
{
// we need to inhibit sending of ::changed because this WILL send a ::changed otherwise
g_signal_handler_block(e->editable, e->onChangedSignal);
gtk_editable_select_region(e->entry, start, end);
g_signal_handler_unblock(e->editable, e->onChangedSignal);
// don't queue the control for resize; entry sizes are independent of their contents
}
void uiEntrySelectAllText(uiEntry *e)
{
uiEntrySelectText(e, 0, -1);
}
void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *, void *), void *data) void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *, void *), void *data)
{ {
e->onChanged = f; e->onChanged = f;