commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

r6068 - in trunk/gnue-forms/src: . uidrivers/gtk2 uidrivers/qt uidrivers


From: reinhard
Subject: r6068 - in trunk/gnue-forms/src: . uidrivers/gtk2 uidrivers/qt uidrivers/wx
Date: Sat, 24 Jul 2004 09:25:00 -0500 (CDT)

Author: reinhard
Date: 2004-07-24 09:24:59 -0500 (Sat, 24 Jul 2004)
New Revision: 6068

Modified:
   trunk/gnue-forms/src/GFDisplayHandler.py
   trunk/gnue-forms/src/uidrivers/gtk2/common.py
   trunk/gnue-forms/src/uidrivers/qt/common.py
   trunk/gnue-forms/src/uidrivers/wx/common.py
Log:
Moved handling of <Enter> key for multiline widgets to GF layer.


Modified: trunk/gnue-forms/src/GFDisplayHandler.py
===================================================================
--- trunk/gnue-forms/src/GFDisplayHandler.py    2004-07-24 14:24:41 UTC (rev 
6067)
+++ trunk/gnue-forms/src/GFDisplayHandler.py    2004-07-24 14:24:59 UTC (rev 
6068)
@@ -266,6 +266,15 @@
     self.cursor     = event.position
     self.delete (event)
 
+  # Handle <Enter> key for multiline entries
+  def __handleENTER(self, event):
+    if gConfigForms('EnterIsNewLine') and \
+       hasattr(self.entry, 'Char__height') and \
+       self.entry.Char__height > 1:
+      event.text = '\n'
+      self.addText(event)
+      event.drop()
+
   # Delete backwards one character
   def backspace(self, event):
     if not self.editing:
@@ -489,6 +498,7 @@
 
                  # "Entry" events
                  'requestKEYPRESS'     : self.addText,
+                 'requestENTER'        : self.__handleENTER,
                  'requestCURSORLEFT'   : self.moveCursorLeft,
                  'requestCURSORRIGHT'  : self.moveCursorRight,
                  'requestCURSOREND'    : self.moveCursorToEnd,

Modified: trunk/gnue-forms/src/uidrivers/gtk2/common.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/common.py       2004-07-24 14:24:41 UTC 
(rev 6067)
+++ trunk/gnue-forms/src/uidrivers/gtk2/common.py       2004-07-24 14:24:59 UTC 
(rev 6068)
@@ -68,29 +68,13 @@
 
   gfObject = uiDriver._WidgetToGFObj [lookup]
 
-  #
-  # Sigh... a hack for using <enter> in multiline entries
-  #
-  if  keycode == gtk.keysyms.Return and \
-      not event.state and \
-      not isinstance (widget, gtk.TextView) and \
-      int (gConfigForms ('enterIsNewLine')) and \
-      (hasattr (gfObject, 'Char__height') and gfObject.Char__height) > 1:
+  # Get the event to process from the KeyMapper
+  command = GFKeyMapper.KeyMapper.getEvent (keycode, isShift, isCtrl, isMod1)
 
-    command = 'NEWLINE'
-
-  else:
-    # Get the event to process from the KeyMapper
-    command = GFKeyMapper.KeyMapper.getEvent (keycode, isShift, isCtrl, isMod1)
-
-
   if command == 'JUMPRECORD':
     global _PROMPTFORRECORD
     action = _PROMPTFORRECORD ()
 
-  elif command == 'NEWLINE':
-    action = events.Event ('requestKEYPRESS', '\n', text='\n', code=10)
-
   elif command:
     action = events.Event ('request%s' % command)
 

Modified: trunk/gnue-forms/src/uidrivers/qt/common.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/common.py 2004-07-24 14:24:41 UTC (rev 
6067)
+++ trunk/gnue-forms/src/uidrivers/qt/common.py 2004-07-24 14:24:59 UTC (rev 
6068)
@@ -115,55 +115,17 @@
     control = state & QKeyEvent.ControlButton
     alt = state & QKeyEvent.AltButton
 
-    #
-    # Sigh... a hack for using <enter> in multiline entries
-    #
-    if  keycode == 13 and \
-       not state and \
-        int (gConfigForms('enterIsNewLine')) and \
-        (hasattr(gfObject,'Char__height') and gfObject.Char__height) > 1:
+    # Get the event to process from the KeyMapper
+    command = GFKeyMapper.KeyMapper.getEvent( keycode, shifted, control, alt)
 
-      command = 'NEWLINE'
+    if command:
+      action = events.Event('request%s' % command)
 
-    else:
+    elif not (control or alt):
+      char = "%s" % event.text()
+      if char:
+        action = events.Event('requestKEYPRESS', char, text=char, code=keycode)
 
-
-      #
-      # Get the event to process from the KeyMapper
-      #
-      command = GFKeyMapper.KeyMapper.getEvent(
-        keycode,
-        shifted,
-        control,
-        alt)
-
-
-      if command == 'NEWLINE':
-        action = events.Event('requestKEYPRESS', '\n',
-                     text='\n',
-                     code=10)
-
-      elif command:
-        action = events.Event('request%s' % command)
-
-
-      elif gfObject._type == 'GFButton':
-        self.animateClick()
-
-      elif gfObject._type == 'GFEntry' and gfObject.style == 'checkbox':
-        # <space> <=> <click>
-        if keycode == 32:
-          action = events.Event('requestTOGGLECHKBOX')
-        else:
-            # maybe some background error message here
-          pass
-      elif not (control or alt):
-        char = "%s" % event.text()
-        if char:
-          action = events.Event('requestKEYPRESS', char,
-                           text=char,
-                           code=keycode)
-
     if action:
       # Add the object's _form to the outgoing event
       # rather than every event in the function

Modified: trunk/gnue-forms/src/uidrivers/wx/common.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/common.py 2004-07-24 14:24:41 UTC (rev 
6067)
+++ trunk/gnue-forms/src/uidrivers/wx/common.py 2004-07-24 14:24:59 UTC (rev 
6068)
@@ -216,39 +216,18 @@
     object = self._uiDriver._IdToGFObj[_eventObjTowxWindow(event).GetId()]
 
     keycode = event.KeyCode()
-    #
-    # Sigh... a hack for using <enter> in multiline entries
-    #
-    if  keycode == 13 and \
-        not event.ShiftDown() and \
-        not event.ControlDown() and \
-        not event.AltDown() and \
-        int (gConfigForms('enterIsNewLine')) and \
-        (hasattr(object,'Char__height') and object.Char__height) > 1:
 
-      command = 'NEWLINE'
+    # Get the event to process from the KeyMapper
+    command = GFKeyMapper.KeyMapper.getEvent(
+      keycode,
+      event.ShiftDown(),
+      event.ControlDown(),
+      event.AltDown())
 
-    else:
-
-
-      #
-      # Get the event to process from the KeyMapper
-      #
-      command = GFKeyMapper.KeyMapper.getEvent(
-        keycode,
-        event.ShiftDown(),
-        event.ControlDown(),
-        event.AltDown())
-
     if command == 'JUMPRECORD':
       global _PROMPTFORRECORD
       action = _PROMPTFORRECORD()
 
-    elif command == 'NEWLINE':
-      action = events.Event('requestKEYPRESS', '\n',
-                     text='\n',
-                     code=10)
-
     # let listbox handle Space,PgUp,PgDn,Up,Down keys
     elif object._type == 'GFEntry' and object.style == 'listbox' and (keycode 
in (32,312,313,317,319)):
         event.Skip()





reply via email to

[Prev in Thread] Current Thread [Next in Thread]