Source code for enamlnative.android.android_edit_text

"""
Copyright (c) 2017-2022, CodeLV.

Distributed under the terms of the MIT License.

The full license is in the file LICENSE, distributed with this software.

Created on May 20, 2017


"""
from atom.api import Typed
from enamlnative.widgets.edit_text import ProxyEditText
from .android_text_view import AndroidTextView, TextView
from .bridge import JavaMethod


class EditText(TextView):
    __nativeclass__ = "android.widget.EditText"
    setSelection = JavaMethod(int, int)
    selectAll = JavaMethod()
    extendSelection = JavaMethod(int)
    setHint = JavaMethod("java.lang.CharSequence")


[docs]class AndroidEditText(AndroidTextView, ProxyEditText): """An Android implementation of an Enaml ProxyEditText.""" #: A reference to the widget created by the proxy. widget = Typed(EditText) # ------------------------------------------------------------------------- # Initialization API # -------------------------------------------------------------------------
[docs] def create_widget(self): """Create the underlying widget.""" d = self.declaration self.widget = EditText( self.get_context(), None, d.style or "@attr/editTextStyle" )
# ------------------------------------------------------------------------- # ProxyEditText API # ------------------------------------------------------------------------- def set_selection(self, selection): self.widget.setSelection(*selection) def set_placeholder(self, placeholder): self.widget.setHint(placeholder)