#
#   Python GUI - Text fields - Generic
#

from Properties import overridable_property
from Applications import application
from Controls import Control

class TextField(Control):
    """A control for entering and editing small amounts of text."""
    
    text = overridable_property('text')
    selection = overridable_property('selection', "Range of text selected.")
    multiline = overridable_property('multiline', "Multiple text lines allowed.")
    password = overridable_property('password', "Display characters obfuscated.")
    
    def setup_menus(self, m):
        selbeg, selend = self.selection
        anysel = selbeg < selend
        anyscrap = application().query_clipboard()
        m.cut_cmd.enabled = anysel
        m.copy_cmd.enabled = anysel
        m.paste_cmd.enabled = anyscrap
        m.clear_cmd.enabled = anysel
