[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8131 - in trunk/gnue-forms: samples/intro src src/input src/uidr
From: |
jamest |
Subject: |
[gnue] r8131 - in trunk/gnue-forms: samples/intro src src/input src/uidrivers/gtk2 src/uidrivers/qt src/uidrivers/win32/widgets src/uidrivers/wx |
Date: |
Thu, 19 Jan 2006 20:12:42 -0600 (CST) |
Author: jamest
Date: 2006-01-19 20:12:41 -0600 (Thu, 19 Jan 2006)
New Revision: 8131
Modified:
trunk/gnue-forms/samples/intro/intro.gfd
trunk/gnue-forms/src/GFForm.py
trunk/gnue-forms/src/GFInstance.py
trunk/gnue-forms/src/input/GFKeyMapper.py
trunk/gnue-forms/src/uidrivers/gtk2/common.py
trunk/gnue-forms/src/uidrivers/qt/common.py
trunk/gnue-forms/src/uidrivers/win32/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx/common.py
Log:
start of allowing user defined triggers against keystrokes
example for CTRL-ALT-G included in intro.gfd
doesn't handle function keys as of yet as I'm not happy with the +64 coded into
GFKeyMapper
and I imagine it'll not work on non-us key setups so checking in for feedback
from others
Modified: trunk/gnue-forms/samples/intro/intro.gfd
===================================================================
--- trunk/gnue-forms/samples/intro/intro.gfd 2006-01-19 02:12:58 UTC (rev
8130)
+++ trunk/gnue-forms/samples/intro/intro.gfd 2006-01-20 02:12:41 UTC (rev
8131)
@@ -77,6 +77,8 @@
'You have a magnetic personality with GNUe forms.',
'Use GNUe and you will notice the extraordinary in the ordinary.']
+print "Beep!"
+form.beep()
if not SampleBlock.YearEntry.isEmpty():
try:
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2006-01-19 02:12:58 UTC (rev 8130)
+++ trunk/gnue-forms/src/GFForm.py 2006-01-20 02:12:41 UTC (rev 8131)
@@ -39,6 +39,7 @@
from gnue.common.datasources import ConnectionTriggerObj
from gnue.forms.GFObjects import *
from gnue.forms import GFParser
+from gnue.common.utils import CaselessDict
#-----------------------------------------------------------------------------
@@ -1395,12 +1396,15 @@
@param modal: whether the dialog should be modal or not
@return: None
"""
+ userParameters = CaselessDict.CaselessDict ()
+ for (k, v) in parameters.items():
+ userParameters [k] = v
- if dialogName == '_about':
- self._instance._uiinstance.showAbout (**parameters)
- else:
- self._instance.activateForm (dialogName, parameters, modal)
-
+ # No longer used?
+ #if dialogName == '_about':
+ # self._instance._uiinstance.showAbout (**parameters)
+ #else:
+ self._instance.activateForm (dialogName, userParameters, modal)
#---------------------------------------------------------------------------
# Close this copy of gnue-forms
Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py 2006-01-19 02:12:58 UTC (rev 8130)
+++ trunk/gnue-forms/src/GFInstance.py 2006-01-20 02:12:41 UTC (rev 8131)
@@ -124,6 +124,7 @@
'requestEXIT' : self.executeExit,
'requestABOUT' : self.executeAbout,
'requestMODETOGGLE' : self.toggleInsertMode,
+ 'requestUSERCOMMAND' : self.executeUserCommand,
'fireTRIGGER' : self.fireTrigger,
'buttonActivated' : self.fireButton,
@@ -137,13 +138,12 @@
# created this GFInstance
self._uimodule = ui # The UI created in the GBaseApp
self._disableSplash = disableSplash # Disable splashscreen
-
+
# The parameters passed to the GBaseApp instance
- if parameters is None:
+ if parameters is None:
self._parameters = CaselessDict.CaselessDict ()
- else:
- self._parameters = parameters
-
+ else:
+ self._parameters = parameters
self._formsDictionary = {} # A dictionary containing all the
# forms loaded from a file
@@ -343,18 +343,12 @@
# Activate a given form
# ---------------------------------------------------------------------------
- def activateForm (self, formName = '__main__', parameters = None, modal = 0):
+ def activateForm (self, formName = '__main__', parameters = None, modal =
False):
assert gEnter (4)
form = self._formsDictionary [formName]
-
-# if parameters:
-# form._parameters = CaselessDict.CaselessDict ()
-# for (k, v) in parameters.items ():
-# form._parameters [k] = v
-
-
+
if not form._currentEntry:
raise errors.ApplicationError, \
u_("There are no navigable widgets in this form. Unable to display.")
@@ -373,6 +367,7 @@
assert gDebug (4, "Activating form")
self._uiinstance.activateForm (formName, modal)
+ #print "Form ", parameters
assert gLeave (4)
@@ -1219,6 +1214,16 @@
event._form.fireTrigger (event.data)
+ def executeUserCommand(self, event):
+ """
+ Fires a trigger
+ """
+ try:
+ event._form.fireTrigger ("KEY-%s" % event.triggerName.upper())
+ except KeyError:
+ pass
+
+
# ---------------------------------------------------------------------------
# Fire the action-trigger bound to a button
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/input/GFKeyMapper.py
===================================================================
--- trunk/gnue-forms/src/input/GFKeyMapper.py 2006-01-19 02:12:58 UTC (rev
8130)
+++ trunk/gnue-forms/src/input/GFKeyMapper.py 2006-01-20 02:12:41 UTC (rev
8131)
@@ -46,23 +46,26 @@
##
class BaseKeyMapper:
"""
- A basic key mapper. This will normally
- serve most UI's input needs.
+ A basic key mapper. This will normally serve most UI's input needs.
+
+ Handles physical to logical key mapping for GNUe Forms.
+ Also performs logical key to Events mapping.
"""
def __init__(self, userKeyMap):
"""
- Constructor
+ Stores the base key map and initializes the translations dict.
"""
self.__functionMap = userKeyMap
self.__keyTranslations = {}
- #
- # This should be called by the UI class to set their
- # key mappings (i.e., we need to know what wxPython
- # thinks F1 is, etc)
- #
+
def setUIKeyMap(self, keyset):
+ """
+ Called by the UI class to setup their required key mappings.
+
+ i.e., we need to know what wxPython thinks F1 is, etc
+ """
self.__keyTranslations = keyset
self._translateUserKeyMap()
@@ -77,7 +80,6 @@
self.__functionMap.update (keymap)
self._translateUserKeyMap()
-
#
# Given a hash of the form:
# { 'PREVBLOCK': 'Ctrl-F1' }
@@ -198,20 +200,35 @@
- #
- # Translate a keystroke into an event.
- # (keystroke is the UI-specific keystroke,
- # not our virtual keys.) Returns None if
- # the keystroke isn't tied to an event.
- #
- # This needs to stay as simple as possible
- # as it gets called for each keystroke
- #
def getEvent(self, basekey, shift=False, ctrl=False, meta=False):
+ """
+ If an event is assigned to the specified keystroke then return
+ that command.
+
+ The keystroke is the UI-specific keystroke, not our virtual keys. If
+ a command isn't defined but a modifier key is held down then a command
+ USERCOMMAND-[CTRL-][ALT-]key will be returned.
+
+ This needs to stay as simple as possible as it gets called for
+ each keystroke
+
+ @return: The command name or None if the keystroke isn't tied to an event.
+ """
try:
- return self._translatedUserKeyMap[(basekey, shift, ctrl, meta)]
+ return (self._translatedUserKeyMap[(basekey, shift, ctrl, meta)], None)
except KeyError:
- return None
+ if (ctrl or meta):
+ actionText = ""
+ if ctrl:
+ basekey += 64 # TODO: Need a real way to get the key pressed when
+ # control is depressed
+
+ actionText += ctrl and 'CTRL-' or ''
+ actionText += meta and 'ALT-' or ''
+ actionText += '%s' % chr(basekey).upper()
+ return ("USERCOMMAND", actionText)
+ else:
+ return (None,None)
#
# Used internally to create a quick lookup
@@ -231,43 +248,43 @@
#
class _VirtualKeys:
"""
- Create a container class for the
- Virtual Key definitions... this
- is to keep our namespace clean.
+ A container class for the Virtual Key definitions.
+
+ This helps keep our namespace clean.
"""
def __init__(self):
- self.F1 = -999
- self.F2 = -998
- self.F3 = -997
- self.F4 = -996
- self.F5 = -995
- self.F6 = -994
- self.F7 = -993
- self.F8 = -992
- self.F9 = -991
- self.F10 = -990
- self.F11 = -989
- self.F12 = -988
- self.INSERT = -987
- self.DELETE = -986
- self.HOME = -985
- self.END = -984
- self.PAGEUP = -983
- self.PAGEDOWN = -982
- self.UP = -981
- self.DOWN = -980
- self.LEFT = -979
- self.RIGHT = -978
- self.TAB = -977
- self.ENTER = -976
- self.RETURN = -975
+ self.F1 = -999
+ self.F2 = -998
+ self.F3 = -997
+ self.F4 = -996
+ self.F5 = -995
+ self.F6 = -994
+ self.F7 = -993
+ self.F8 = -992
+ self.F9 = -991
+ self.F10 = -990
+ self.F11 = -989
+ self.F12 = -988
+ self.INSERT = -987
+ self.DELETE = -986
+ self.HOME = -985
+ self.END = -984
+ self.PAGEUP = -983
+ self.PAGEDOWN = -982
+ self.UP = -981
+ self.DOWN = -980
+ self.LEFT = -979
+ self.RIGHT = -978
+ self.TAB = -977
+ self.ENTER = -976
+ self.RETURN = -975
self.BACKSPACE = -974
- self.X = -973
- self.V = -972
- self.C = -971
- self.A = -970
- self.Q = -969
+ self.X = -973
+ self.V = -972
+ self.C = -971
+ self.A = -970
+ self.Q = -969
#
@@ -301,10 +318,9 @@
return None
-#####################################################################
-#
-# Default event mappings
-#
+# =============================================================================
+# Default key to command event mappings
+# =============================================================================
DefaultMapping = {
# (Key, Shifted, Ctrl'd, Meta/Alt'd)
@@ -356,9 +372,7 @@
(vk.ENTER, True, False, False) : 'NEWLINE',
}
-
#
-# The application will only
-# need one instance, so create one.
+# The application will only need one instance, so create one.
#
KeyMapper = BaseKeyMapper(DefaultMapping)
Modified: trunk/gnue-forms/src/uidrivers/gtk2/common.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/common.py 2006-01-19 02:12:58 UTC
(rev 8130)
+++ trunk/gnue-forms/src/uidrivers/gtk2/common.py 2006-01-20 02:12:41 UTC
(rev 8131)
@@ -75,10 +75,10 @@
gfObject = uiDriver._WidgetToGFObj [lookup]
# Get the event to process from the KeyMapper
- command = GFKeyMapper.KeyMapper.getEvent (keycode, isShift, isCtrl, isMod1)
+ command, argument = GFKeyMapper.KeyMapper.getEvent (keycode, isShift,
isCtrl, isMod1)
if command:
- action = events.Event ('request%s' % command)
+ action = events.Event ('request%s' % command, argument=argument)
# Add the gfObject's _form to the outgoing event
# rather than every event in the function
Modified: trunk/gnue-forms/src/uidrivers/qt/common.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/common.py 2006-01-19 02:12:58 UTC (rev
8130)
+++ trunk/gnue-forms/src/uidrivers/qt/common.py 2006-01-20 02:12:41 UTC (rev
8131)
@@ -116,10 +116,10 @@
alt = state & QKeyEvent.AltButton
# Get the event to process from the KeyMapper
- command = GFKeyMapper.KeyMapper.getEvent( keycode, shifted, control, alt)
+ command, args = GFKeyMapper.KeyMapper.getEvent( keycode, shifted, control,
alt)
if command:
- action = events.Event('request%s' % command)
+ action = events.Event('request%s' % command, arguments=args)
elif not (control or alt):
char = "%s" % event.text()
Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/_base.py 2006-01-19
02:12:58 UTC (rev 8130)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/_base.py 2006-01-20
02:12:41 UTC (rev 8131)
@@ -47,15 +47,15 @@
#TCN_SELCHANGE = (commctrl.TCN_FIRST - 1)
#TCN_SELCHANGING = (commctrl.TCN_FIRST - 2)
-
-# user defined events for edit part of dropdown
-WM_TAB = win32con.WM_USER
-WM_RETURN = win32con.WM_USER + 1
-
-def _MyCallback( hwnd, windows ):
- windows.append(hwnd)
-
+# user defined events for edit part of dropdown
+WM_TAB = win32con.WM_USER
+WM_RETURN = win32con.WM_USER + 1
+
+def _MyCallback( hwnd, windows ):
+ windows.append(hwnd)
+
+
class Win32Base:
_connectTable = {}
@@ -80,67 +80,67 @@
self._uiDriver = uidriver
self._uiDriver._win32app._HwndToTkObj[self._hwnd] = self
- if className in ['STATIC', 'BUTTON', 'COMBOBOX', 'LISTBOX', 'EDIT']:
- # subclassing edit control part of the combo box eventhandler
+ if className in ['STATIC', 'BUTTON', 'COMBOBOX', 'LISTBOX', 'EDIT']:
+ # subclassing edit control part of the combo box eventhandler
# to produce incremental search/autocomplete
- if className == 'COMBOBOX':
+ if className == 'COMBOBOX':
self._AutoComplete = True
- windows = []
- try:
- win32gui.EnumChildWindows(self._hwnd, _MyCallback, windows)
- self._editHwnd = windows[0]
- self._oldWndProc1 = win32gui.SetWindowLong(self._editHwnd,
win32con.GWL_WNDPROC, self._wndproc1)
- except:
- pass
-
+ windows = []
+ try:
+ win32gui.EnumChildWindows(self._hwnd, _MyCallback, windows)
+ self._editHwnd = windows[0]
+ self._oldWndProc1 = win32gui.SetWindowLong(self._editHwnd,
win32con.GWL_WNDPROC, self._wndproc1)
+ except:
+ pass
+
self.Show()
self._oldWndProc = win32gui.SetWindowLong(self._hwnd,
win32con.GWL_WNDPROC, self._wndproc)
-
- # edit control part of the combo box eventhandler
- def _wndproc1(self, hwnd, msg, wParam, lParam):
- if msg == win32con.WM_LBUTTONDOWN:
+
+ # edit control part of the combo box eventhandler
+ def _wndproc1(self, hwnd, msg, wParam, lParam):
+ if msg == win32con.WM_LBUTTONDOWN:
gfObject = self._uiDriver._IdToGFObj[self._id]
- uiObject = self._uiDriver._IdToUIObj[self._id]
-
+ uiObject = self._uiDriver._IdToUIObj[self._id]
+
uiObject._eventHandler('requestFOCUS',gfObject,_form=gfObject._form)
count = uiObject.widgets.index(self)
uiObject._eventHandler('requestJUMPRECORD',count -
gfObject._visibleIndex,_form=gfObject._form)
elif msg == win32con.WM_KEYDOWN:
- keycode = wParam
- self._AutoComplete = True
-
+ keycode = wParam
+ self._AutoComplete = True
+
# let the delete/back keys do their job
- if keycode in (win32con.VK_DELETE, win32con.VK_BACK):
- self._AutoComplete = False
-
- elif keycode == win32con.VK_TAB:
- # we have to deal with tab and enter
- ShiftDown = (win32api.GetKeyState(win32con.VK_SHIFT) & 0x8000) and 1
or 0
- if ShiftDown:
- win32gui.SendMessage(self._hwnd, WM_TAB, 0, 1)
+ if keycode in (win32con.VK_DELETE, win32con.VK_BACK):
+ self._AutoComplete = False
+
+ elif keycode == win32con.VK_TAB:
+ # we have to deal with tab and enter
+ ShiftDown = (win32api.GetKeyState(win32con.VK_SHIFT) & 0x8000) and 1
or 0
+ if ShiftDown:
+ win32gui.SendMessage(self._hwnd, WM_TAB, 0, 1)
else:
- win32gui.SendMessage(self._hwnd, WM_TAB, 0, 0)
- return 0
-
- elif keycode == win32con.VK_RETURN:
- win32gui.SendMessage(self._hwnd, WM_RETURN, 0, 0)
- return 0
-
+ win32gui.SendMessage(self._hwnd, WM_TAB, 0, 0)
+ return 0
+
+ elif keycode == win32con.VK_RETURN:
+ win32gui.SendMessage(self._hwnd, WM_RETURN, 0, 0)
+ return 0
+
elif keycode in F_KEYS:
- win32gui.SendMessage(self._hwnd, msg, wParam, lParam)
- return 0
-
+ win32gui.SendMessage(self._hwnd, msg, wParam, lParam)
+ return 0
+
elif msg == win32con.WM_CHAR:
- keycode = wParam
- if keycode in (win32con.VK_TAB, win32con.VK_RETURN):
- return 0
+ keycode = wParam
+ if keycode in (win32con.VK_TAB, win32con.VK_RETURN):
+ return 0
return win32gui.CallWindowProc(self._oldWndProc1, hwnd, msg, wParam,
lParam)
-
+
# main eventhandler
- def _wndproc(self, hwnd, msg, wParam, lParam):
- if msg == win32con.WM_LBUTTONDOWN:
+ def _wndproc(self, hwnd, msg, wParam, lParam):
+ if msg == win32con.WM_LBUTTONDOWN:
gfObject = self._uiDriver._IdToGFObj[self._id]
uiObject = self._uiDriver._IdToUIObj[self._id]
@@ -181,11 +181,11 @@
gfObject = self._uiDriver._IdToGFObj[self._id]
if (keycode in NOT_WM_CHAR_KEYS):
- if gfObject._type == 'GFEntry' and \
- gfObject.style in ('dropdown', 'listbox') and \
+ if gfObject._type == 'GFEntry' and \
+ gfObject.style in ('dropdown', 'listbox') and \
keycode not in F_KEYS:
- return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
-
+ return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
+
else:
action = None
@@ -193,42 +193,42 @@
ControlDown = (win32api.GetKeyState(win32con.VK_CONTROL) & 0x8000)
and 1 or 0
AltDown = (win32api.GetKeyState(win32con.VK_MENU) & 0x8000) and 1 or 0
- command = GFKeyMapper.KeyMapper.getEvent(
+ command, args = GFKeyMapper.KeyMapper.getEvent(
keycode,
ShiftDown,
ControlDown,
AltDown)
- if command:
- uiObject = self._uiDriver._IdToUIObj[self._id]
- # handle up and down arrows in multiline edit
- if gfObject._type == 'GFEntry' and \
+ if command:
+ uiObject = self._uiDriver._IdToUIObj[self._id]
+ # handle up and down arrows in multiline edit
+ if gfObject._type == 'GFEntry' and \
hasattr(gfObject,'Char__height') and gfObject.Char__height > 1
and \
- keycode in (win32con.VK_UP, win32con.VK_DOWN):
-
- lines = win32gui.SendMessage(hwnd, win32con.EM_GETLINECOUNT, 0,
0)
- line = win32gui.SendMessage(hwnd, win32con.EM_LINEFROMCHAR, -1,
0)
-
- if line == 0 and keycode == win32con.VK_UP:
+ keycode in (win32con.VK_UP, win32con.VK_DOWN):
+
+ lines = win32gui.SendMessage(hwnd, win32con.EM_GETLINECOUNT, 0,
0)
+ line = win32gui.SendMessage(hwnd, win32con.EM_LINEFROMCHAR, -1,
0)
+
+ if line == 0 and keycode == win32con.VK_UP:
uiObject._request ('PREVENTRY')
- elif line == lines-1 and keycode == win32con.VK_DOWN:
- uiObject._request ('NEXTENTRY')
+ elif line == lines-1 and keycode == win32con.VK_DOWN:
+ uiObject._request ('NEXTENTRY')
else:
- win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
- pos = self.getSelectedArea ()[0]
+ win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
+ pos = self.getSelectedArea ()[0]
uiObject._request ('CURSORMOVE', position = pos)
else:
- action = events.Event('request%s' % command)
+ action = events.Event('request%s' % command, arguments=args)
# Add the object's _form to the outgoing event
# rather than every event in the function
action.__dict__.update({'_form':gfObject._form})
uiObject._eventHandler(action)
-
- win32gui.SendMessage(hwnd, win32con.EM_SCROLLCARET, 0, 0)
+ win32gui.SendMessage(hwnd, win32con.EM_SCROLLCARET, 0, 0)
+
elif msg == win32con.WM_CHAR:
# The TranslateMessage function generates a WM_CHAR message
# when the user presses any of the following keys:
@@ -297,59 +297,59 @@
action.__dict__.update({'_form':gfObject._form})
uiObject = self._uiDriver._IdToUIObj[self._id]
uiObject._eventHandler(action)
-
- win32gui.SendMessage(hwnd, win32con.EM_SCROLLCARET, 0, 0)
+ win32gui.SendMessage(hwnd, win32con.EM_SCROLLCARET, 0, 0)
+
if gfObject._type == 'GFEntry':
- if gfObject.style == 'dropdown' or gfObject.style == 'listbox':
+ if gfObject.style == 'dropdown' or gfObject.style == 'listbox':
return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
- elif msg == win32con.WM_COMMAND:
+ elif msg == win32con.WM_COMMAND:
gfObject = self._uiDriver._IdToGFObj[self._id]
- uiObject = self._uiDriver._IdToUIObj[self._id]
-
- if gfObject.style == 'dropdown':
- # Autocompletition goes here:
- # First find if there any element in the dropdown wth prefix matching,
then
- # select it with CB_SELECTSTRING, then
- # highlight(select) the not typed yet part of the string
- if win32api.HIWORD(wParam) == win32con.EN_UPDATE and
self._AutoComplete:
-
- text = win32gui.GetWindowText(hwnd)
- length = len(text)
+ uiObject = self._uiDriver._IdToUIObj[self._id]
+
+ if gfObject.style == 'dropdown':
+ # Autocompletition goes here:
+ # First find if there any element in the dropdown wth prefix matching,
then
+ # select it with CB_SELECTSTRING, then
+ # highlight(select) the not typed yet part of the string
+ if win32api.HIWORD(wParam) == win32con.EN_UPDATE and
self._AutoComplete:
+
+ text = win32gui.GetWindowText(hwnd)
+ length = len(text)
gs = win32gui.SendMessage(self._editHwnd, win32con.EM_GETSEL, 0, 0)
(start, end) = (win32api.LOWORD(gs), win32api.HIWORD(gs))
-
- if win32gui.SendMessage(hwnd, win32con.CB_SELECTSTRING, -1, text) ==
win32con.CB_ERR:
- win32gui.SetWindowText(self._editHwnd, text)
-
- selection = self.GetValue()
- if selection >= 0:
- string = gfObject._field.allowedValues()[1][selection]
+
+ if win32gui.SendMessage(hwnd, win32con.CB_SELECTSTRING, -1, text) ==
win32con.CB_ERR:
+ win32gui.SetWindowText(self._editHwnd, text)
+
+ selection = self.GetValue()
+ if selection >= 0:
+ string = gfObject._field.allowedValues()[1][selection]
uiObject._eventHandler('requestREPLACEVALUE',object=gfObject,
index=selection, text=string,
- _form=gfObject._form)
-
- if end < length:
- win32gui.SendMessage(self._editHwnd, win32con.EM_SETSEL, start,
end)
- else:
- win32gui.SendMessage(self._editHwnd, win32con.EM_SETSEL, length,
-1)
-
- # selection from listbox part of dropdown with mouse or arrows
- elif win32api.HIWORD(wParam) == win32con.CBN_SELCHANGE:
- selection = self.GetValue()
- if selection >= 0:
- string = gfObject._field.allowedValues()[1][selection]
+ _form=gfObject._form)
+
+ if end < length:
+ win32gui.SendMessage(self._editHwnd, win32con.EM_SETSEL, start,
end)
+ else:
+ win32gui.SendMessage(self._editHwnd, win32con.EM_SETSEL, length,
-1)
+
+ # selection from listbox part of dropdown with mouse or arrows
+ elif win32api.HIWORD(wParam) == win32con.CBN_SELCHANGE:
+ selection = self.GetValue()
+ if selection >= 0:
+ string = gfObject._field.allowedValues()[1][selection]
uiObject._eventHandler('requestREPLACEVALUE',object=gfObject,
index=selection, text=string,
- _form=gfObject._form)
- return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
+ _form=gfObject._form)
+ return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
else:
- return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
+ return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
else:
- return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
-
+ return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
+
elif msg == win32con.WM_PAINT:
try:
gfObject = self._uiDriver._IdToGFObj[self._id]
@@ -363,34 +363,34 @@
win32gui.ReleaseDC(self._hwnd,hdc)
else:
return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
-
- # user defined events for edit part of dropdown
- elif msg == WM_TAB or msg == WM_RETURN:
+
+ # user defined events for edit part of dropdown
+ elif msg == WM_TAB or msg == WM_RETURN:
gfObject = self._uiDriver._IdToGFObj[self._id]
uiObject = self._uiDriver._IdToUIObj[self._id]
-
- text = win32gui.GetWindowText(hwnd)
- win32gui.SendMessage(hwnd, win32con.CB_SELECTSTRING, -1, text)
-
- selection = self.GetValue()
- if selection == -1:
- selection = 0
-
- string = gfObject._field.allowedValues()[1][selection]
+
+ text = win32gui.GetWindowText(hwnd)
+ win32gui.SendMessage(hwnd, win32con.CB_SELECTSTRING, -1, text)
+
+ selection = self.GetValue()
+ if selection == -1:
+ selection = 0
+
+ string = gfObject._field.allowedValues()[1][selection]
uiObject._eventHandler('requestREPLACEVALUE',object=gfObject,
index=selection, text=string,
- _form=gfObject._form)
+ _form=gfObject._form)
if lParam == 1:
- action = events.Event('requestPREVENTRY')
+ action = events.Event('requestPREVENTRY')
else:
- action = events.Event('requestNEXTENTRY')
+ action = events.Event('requestNEXTENTRY')
action.__dict__.update({'_form':gfObject._form})
- uiObject._eventHandler(action)
+ uiObject._eventHandler(action)
else:
return win32gui.CallWindowProc(self._oldWndProc, hwnd, msg, wParam,
lParam)
-
+
def SetFont(self, font):
self._PyCWnd.SetFont(font,1)
@@ -465,7 +465,7 @@
elif child._className == commctrl.TOOLBARCLASSNAME:
win32gui.SendMessage(child.GetHwnd(), commctrl.TB_AUTOSIZE, 0, 0)
- def OnWMCommand(self, hwnd, msg, wParam, lParam):
+ def OnWMCommand(self, hwnd, msg, wParam, lParam):
# menu/toolbar selection happend'
self._connectTable[wParam]()
@@ -512,10 +512,10 @@
else:
win32gui.SendMessage(self._hwnd, win32con.LB_SETCURSEL, 0, 0)
else:
- if hasattr(gfObject,'Char__height') and gfObject.Char__height > 1:
- corrvalue = '\r\n'.join (value.splitlines ())
- if len(value) and value[-1] == '\n':
- corrvalue += '\r\n'
+ if hasattr(gfObject,'Char__height') and gfObject.Char__height > 1:
+ corrvalue = '\r\n'.join (value.splitlines ())
+ if len(value) and value[-1] == '\n':
+ corrvalue += '\r\n'
win32gui.SetWindowText(self._hwnd, corrvalue)
else:
win32gui.SetWindowText(self._hwnd, str(value))
@@ -788,8 +788,8 @@
vk.ENTER : win32con.VK_RETURN, vk.BACKSPACE : win32con.VK_BACK }
GFKeyMapper.KeyMapper.setUIKeyMap(win32KeyTranslations)
-
-F_KEYS = [
+
+F_KEYS = [
win32con.VK_F1,
win32con.VK_F2,
win32con.VK_F3,
Modified: trunk/gnue-forms/src/uidrivers/wx/common.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/common.py 2006-01-19 02:12:58 UTC (rev
8130)
+++ trunk/gnue-forms/src/uidrivers/wx/common.py 2006-01-20 02:12:41 UTC (rev
8131)
@@ -234,7 +234,7 @@
keycode = event.KeyCode()
# Get the event to process from the KeyMapper
- command = GFKeyMapper.KeyMapper.getEvent(
+ command, args = GFKeyMapper.KeyMapper.getEvent(
keycode,
event.ShiftDown(),
event.ControlDown(),
@@ -245,8 +245,15 @@
event.Skip()
elif command:
- action = events.Event('request%s' % command)
+ print command
+ action = events.Event('request%s' % command, triggerName = args)
+# elif event.ControlDown() or event.AltDown():
+# actionText = ""
+# actionText += event.ControlDown() and 'CTRL-' or ''
+# actionText += event.AltDown() and 'ALT-' or ''
+# actionText += '%s' % chr(keycode)
+# action = events.Event('requestUSERCOMMAND', triggerName = actionText)
else:
try:
char = chr(keycode)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8131 - in trunk/gnue-forms: samples/intro src src/input src/uidrivers/gtk2 src/uidrivers/qt src/uidrivers/win32/widgets src/uidrivers/wx,
jamest <=