Ui text: Add an editable variant (tiny wrapper).
As part of this commit, also add a way to change whether the widget is editable or not.
This commit is contained in:
parent
56562b1643
commit
2fd8861874
|
@ -140,6 +140,7 @@ elm_public_eolian_files = \
|
|||
lib/elementary/elm_code_widget.eo \
|
||||
lib/elementary/efl_ui_text_interactive.eo \
|
||||
lib/elementary/efl_ui_text.eo \
|
||||
lib/elementary/efl_ui_text_editable.eo \
|
||||
$(NULL)
|
||||
|
||||
# Private classes (not exposed or shipped)
|
||||
|
|
|
@ -278,6 +278,7 @@ EAPI extern Elm_Version *elm_version;
|
|||
# include <efl_ui_win_standard.eo.h>
|
||||
# include <efl_ui_text_interactive.eo.h>
|
||||
# include <efl_ui_text.eo.h>
|
||||
# include <efl_ui_text_editable.eo.h>
|
||||
#endif
|
||||
|
||||
/* include deprecated calls last of all */
|
||||
|
|
|
@ -21,6 +21,7 @@ typedef struct _Efl_Ui_Internal_Text_Interactive_Data
|
|||
Eina_Bool selecting : 1;
|
||||
Eina_Bool have_selection : 1;
|
||||
Eina_Bool select_allow : 1;
|
||||
Eina_Bool editable : 1;
|
||||
Eina_Bool had_sel : 1;
|
||||
Eina_Bool input_panel_enable : 1;
|
||||
Eina_Bool prediction_allow : 1;
|
||||
|
@ -709,6 +710,10 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
|
|||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
|
||||
Efl_Ui_Internal_Text_Interactive_Data *en = eo_data_scope_get(obj, MY_CLASS);
|
||||
|
||||
/* FIXME: Maybe allow selctions to happen even when not editable. */
|
||||
if (!en->editable) return;
|
||||
|
||||
cur = efl_canvas_text_cursor_get(obj);
|
||||
old_cur_pos = evas_textblock_cursor_pos_get(cur);
|
||||
|
||||
|
@ -1272,6 +1277,7 @@ _efl_ui_internal_text_interactive_eo_base_constructor(Eo *obj, Efl_Ui_Internal_T
|
|||
{
|
||||
en->select_allow = EINA_TRUE;
|
||||
en->multiline = EINA_TRUE;
|
||||
en->editable = EINA_TRUE;
|
||||
return eo_constructor(eo_super(obj, MY_CLASS));
|
||||
}
|
||||
|
||||
|
@ -1391,6 +1397,17 @@ _efl_ui_internal_text_interactive_efl_ui_text_interactive_multiline_get(Eo *obj
|
|||
return pd->multiline;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_internal_text_interactive_efl_ui_text_interactive_editable_set(Eo *obj EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *sd, Eina_Bool editable)
|
||||
{
|
||||
sd->editable = editable;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_ui_internal_text_interactive_efl_ui_text_interactive_editable_get(Eo *obj EINA_UNUSED, Efl_Ui_Internal_Text_Interactive_Data *sd)
|
||||
{
|
||||
return sd->editable;
|
||||
}
|
||||
|
||||
#include "efl_ui_internal_text_interactive.eo.c"
|
||||
#include "efl_ui_text_interactive.eo.c"
|
||||
|
|
|
@ -10,5 +10,6 @@ class Efl.Ui.Internal.Text.Interactive (Efl.Canvas.Text, Efl.Ui.Text.Interactive
|
|||
Efl.Ui.Text.Interactive.selection_allowed;
|
||||
Efl.Ui.Text.Interactive.selection_cursors.get;
|
||||
Efl.Ui.Text.Interactive.multiline;
|
||||
Efl.Ui.Text.Interactive.editable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ struct _Efl_Ui_Text_Data
|
|||
Eina_Bool can_write : 1;
|
||||
Eina_Bool auto_save : 1;
|
||||
Eina_Bool password : 1;
|
||||
Eina_Bool editable : 1;
|
||||
Eina_Bool editable : 1; // FIXME: This is redundant because of text interactive and should be removed
|
||||
Eina_Bool disabled : 1;
|
||||
Eina_Bool h_bounce : 1;
|
||||
Eina_Bool v_bounce : 1;
|
||||
|
@ -4086,6 +4086,7 @@ _efl_ui_text_eo_base_constructor(Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED)
|
|||
elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_ENTRY);
|
||||
eo_event_callback_add(obj, EO_EVENT_CALLBACK_ADD, _cb_added, NULL);
|
||||
eo_event_callback_add(obj, EO_EVENT_CALLBACK_DEL, _cb_deleted, NULL);
|
||||
efl_ui_text_interactive_editable_set(obj, EINA_FALSE);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@ -4183,8 +4184,9 @@ _efl_ui_text_entry_insert(Eo *obj, Efl_Ui_Text_Data *sd, const char *entry)
|
|||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_text_editable_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool editable)
|
||||
_efl_ui_text_efl_ui_text_interactive_editable_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool editable)
|
||||
{
|
||||
efl_ui_text_interactive_editable_set(eo_super(obj, MY_CLASS), editable);
|
||||
if (sd->editable == editable) return;
|
||||
sd->editable = editable;
|
||||
elm_obj_widget_theme_apply(obj);
|
||||
|
@ -4205,12 +4207,6 @@ _efl_ui_text_editable_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool editable)
|
|||
}
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_ui_text_editable_get(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
||||
{
|
||||
return sd->editable;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_ui_text_select_none(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
||||
{
|
||||
|
@ -5416,7 +5412,7 @@ _efl_ui_text_elm_interface_atspi_accessible_state_set_get(Eo *obj, Efl_Ui_Text_D
|
|||
Elm_Atspi_State_Set ret;
|
||||
ret = elm_interface_atspi_accessible_state_set_get(eo_super(obj, EFL_UI_TEXT_CLASS));
|
||||
|
||||
if (efl_ui_text_editable_get(obj))
|
||||
if (efl_ui_text_interactive_editable_get(obj))
|
||||
STATE_TYPE_SET(ret, ELM_ATSPI_STATE_EDITABLE);
|
||||
|
||||
return ret;
|
||||
|
@ -5637,3 +5633,16 @@ ELM_PART_OVERRIDE_CONTENT_UNSET(elm_entry, EFL_UI_TEXT, ELM_LAYOUT, Efl_Ui_Text_
|
|||
|
||||
#include "efl_ui_text.eo.c"
|
||||
|
||||
#undef MY_CLASS
|
||||
#define MY_CLASS EFL_UI_TEXT_EDITABLE_CLASS
|
||||
|
||||
EOLIAN static Eo *
|
||||
_efl_ui_text_editable_eo_base_constructor(Eo *obj, void *_pd EINA_UNUSED)
|
||||
{
|
||||
obj = eo_constructor(eo_super(obj, MY_CLASS));
|
||||
efl_ui_text_interactive_editable_set(obj, EINA_TRUE);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
#include "efl_ui_text_editable.eo.c"
|
||||
|
|
|
@ -134,28 +134,6 @@ class Efl.Ui.Text (Elm.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
|
|||
autocapital_type: Elm.Autocapital.Type; [[The type of autocapitalization.]]
|
||||
}
|
||||
}
|
||||
@property editable {
|
||||
set {
|
||||
[[Sets if the entry is to be editable or not.
|
||||
|
||||
By default, entries are editable and when focused, any text input by the
|
||||
user will be inserted at the current cursor position. But calling this
|
||||
function with $editable as $false will prevent the user from
|
||||
inputting text into the entry.
|
||||
|
||||
The only way to change the text of a non-editable entry is to use
|
||||
\@ref elm_object_text_set, \@ref elm_entry_entry_insert and other related
|
||||
functions.
|
||||
]]
|
||||
}
|
||||
get {
|
||||
[[Get whether the entry is editable or not.]]
|
||||
}
|
||||
values {
|
||||
editable: bool; [[If $true, user input will be inserted in the entry,
|
||||
if not, the entry is read-only and no user input is allowed.]]
|
||||
}
|
||||
}
|
||||
@property password {
|
||||
set {
|
||||
[[Sets the entry to password mode.
|
||||
|
@ -440,6 +418,7 @@ class Efl.Ui.Text (Elm.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
|
|||
Elm.Interface.Atspi.Text.Editable.paste;
|
||||
Efl.File.file.set;
|
||||
Efl.File.file.get;
|
||||
Efl.Ui.Text.Interactive.editable.set;
|
||||
}
|
||||
events {
|
||||
activated;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class Efl.Ui.Text.Editable (Efl.Ui.Text)
|
||||
{
|
||||
data: null;
|
||||
implements {
|
||||
Eo.Base.constructor;
|
||||
}
|
||||
}
|
|
@ -45,6 +45,21 @@ interface Efl.Ui.Text.Interactive ()
|
|||
enabled: bool; [[$true if enabled]]
|
||||
}
|
||||
}
|
||||
@property editable {
|
||||
[[Whether the entry is editable.
|
||||
|
||||
By default text interactives are editable. However, setting this
|
||||
property to $false will make it so key input will be disregarded.
|
||||
]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
editable: bool; [[If $true, user input will be inserted in the entry,
|
||||
if not, the entry is read-only and no user input is allowed.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
events {
|
||||
changed,user: Efl.Ui.Text.Interactive.Change_Info; [[The text object has changed due to user interaction]]
|
||||
|
|
Loading…
Reference in New Issue