UI: Try limiting 'x' icon to search buttons
Reusing PROP_TEXTEDIT_UPDATE instead of adding a new property flag just for search strings. Currently it's only used for search strings anyway so seems fine for now. Fixes T50336.
This commit is contained in:
parent
c910beaa21
commit
c4f60319d1
Notes:
blender-bot
2023-02-14 07:18:55 +01:00
Referenced by issue #50336, The 'X' buttons on text fields
|
@ -119,12 +119,10 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
|
|||
else
|
||||
but = uiDefButR_prop(block, UI_BTYPE_TEXT, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
||||
|
||||
PropertySubType subtype = RNA_property_subtype(prop);
|
||||
if (!(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME) || (block->flag & UI_BLOCK_LIST_ITEM))) {
|
||||
UI_but_flag_enable(but, UI_BUT_VALUE_CLEAR);
|
||||
}
|
||||
if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) {
|
||||
UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE);
|
||||
/* TEXTEDIT_UPDATE is usally used for search buttons. For these we also want
|
||||
* the 'x' icon to clear search string, so setting VALUE_CLEAR flag, too. */
|
||||
UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE | UI_BUT_VALUE_CLEAR);
|
||||
}
|
||||
break;
|
||||
case PROP_POINTER:
|
||||
|
|
|
@ -174,8 +174,10 @@ typedef enum PropertyFlag {
|
|||
* and collections */
|
||||
PROP_ANIMATABLE = (1 << 1),
|
||||
|
||||
/* This flag means when the property's widget is in 'textedit' mode, it will be updated after every typed char,
|
||||
* instead of waiting final validation. Used e.g. for text searchbox. */
|
||||
/* This flag means when the property's widget is in 'textedit' mode, it will be updated
|
||||
* after every typed char, instead of waiting final validation. Used e.g. for text searchbox.
|
||||
* It will also cause UI_BUT_VALUE_CLEAR to be set for text buttons. We could add an own flag
|
||||
* for search/filter properties, but this works just fine for now. */
|
||||
PROP_TEXTEDIT_UPDATE = (1 << 31),
|
||||
|
||||
/* icon */
|
||||
|
|
Loading…
Reference in New Issue