#10 Edit Box Need Enable/ReadOnly

closed
nobody
widgets (7)
5
2003-04-13
2003-02-27
No

EditBox needs a "ReadOnly" type setting or just enable
like the buttons have. That way the prog. can set the
value, but not the user

Discussion

  • Chris Rodrigues

    Chris Rodrigues - 2003-04-05

    Logged In: YES
    user_id=571002

    This should do the trick. Set Edit.readOnly to true to make the edit-box
    readonly. Apply the patch to widgets.py.

    --- widgets.py Sat Mar 1 15:21:03 2003
    +++ ../widgets.py Sat Apr 5 02:13:34 2003
    @@ -264,7 +264,7 @@
    """
    canTab = 1
    widgetLabel = "Edit"
    - def __init__(self,text, max, handler):
    + def __init__(self,text, max, handler, readOnly = 0):
    Base.__init__(self)
    self.handler = handler
    self.caretPos = None
    @@ -272,6 +272,7 @@
    self.setText(text)
    self.dragging = 0
    self.max = max
    + self.readOnly = readOnly
    self.resize(self.width, int(getRenderer().getTextSize("x")[1] * 1.5) )
    #print "Edit widget sized to", self.width, self.height
    self.registerEvent(pyui.locals.KEYDOWN, self._pyuiKeyDown)
    @@ -417,6 +418,10 @@
    self.setDirty()
    return 1

    + # do not allow modification if edit is read-only
    + if self.readOnly:
    + return 0
    +
    if event.key == pyui.locals.K_BACKSPACE:
    if self.selectPos != self.caretPos:
    self.deleteSelected()
    @@ -457,6 +462,10 @@
    if not self.hasFocus():
    return 0

    + # do not allow modification if edit is read-only
    + if self.readOnly:
    + return 0
    +
    if ord(event.key) < 32 or ord(event.key) > 128:
    return 0

     
  • Sean Riley

    Sean Riley - 2003-04-13

    Logged In: YES
    user_id=212712

    Patch applied for 0.96 release

     
  • Sean Riley

    Sean Riley - 2003-04-13
    • status: open --> closed
     

Log in to post a comment.