FloatCtrl?

MURADI OZSOYLER wrote:

Hi Will,

As I mentioned on the list several weeks ago, NumCtrl uses '.' key to
jump to decimal part even if the decimalChar is ','. It separates the
decimal part with ',' though, which is correct.

Is there a patch/workaround for this?

Thanks in advance,

Murat

Oops; Sorry, I must have missed your posting...

This has been broken for a while, and is is due to an overeager attempt
on my part to make the code efficient. I will submit the patch to Robin
directly, but for now, the fix is:

diff -u -1 -0 -r1.16 maskededit.py
--- maskededit.py 2005/04/08 21:31:25 1.16
+++ maskededit.py 2005/06/21 19:42:47
@@ -2667,28 +2667,29 @@
             # Replace up/down arrow default handling:
             # make down act like tab, up act like shift-tab:

#### dbg('Registering numeric navigation and control handlers
(if not already set)')
             if not self._keyhandlers.has_key(wx.WXK_DOWN):
                 self._SetKeycodeHandler(wx.WXK_DOWN, self._OnChangeField)
             if not self._keyhandlers.has_key(wx.WXK_UP):
                 self._SetKeycodeHandler(wx.WXK_UP, self._OnUpNumeric) #
(adds "shift" to up arrow, and calls _OnChangeField)

             # On ., truncate contents right of cursor to decimal point (if
any)
- # leaves cusor after decimal point if floating point, otherwise
at 0.
- if not self._keyhandlers.has_key(ord(self._decimalChar)):
+ # leaves cursor after decimal point if floating point,
otherwise at 0.
+ if not self._keyhandlers.has_key(ord(self._decimalChar)) or
self._keyhandlers[ord(self._decimalChar)] != self._OnDecimalPoint:
                 self._SetKeyHandler(self._decimalChar,
self._OnDecimalPoint)
- if not self._keyhandlers.has_key(ord(self._shiftDecimalChar)):

···

+
+ if not self._keyhandlers.has_key(ord(self._shiftDecimalChar))
or self._keyhandlers[ord(self._shiftDecimalChar)] != self._OnChangeField:
                 self._SetKeyHandler(self._shiftDecimalChar,
self._OnChangeField) # (Shift-'.' == '>' on US keyboards)

             # Allow selective insert of groupchar in numbers:
- if not
self._keyhandlers.has_key(ord(self._fields[0]._groupChar)):
+ if not
self._keyhandlers.has_key(ord(self._fields[0]._groupChar)) or
self._keyhandlers[ord(self._fields[0]._groupChar)] != self._OnGroupChar:
                 self._SetKeyHandler(self._fields[0]._groupChar,
self._OnGroupChar)

## dbg(indent=0, suspend=0)

     def _SetInitialValue(self, value=""):
         """
         fills the control with the generated or supplied default value.
         It will also set/reset the font if necessary and apply
         formatting to the control at this time.

Hi Will,

After applying the patch it works just as expected. Thank you.

Regards,

Murat Özsöyler

Will Sadkin wrote:

···

MURADI OZSOYLER wrote:

Hi Will,

As I mentioned on the list several weeks ago, NumCtrl uses '.' key to
jump to decimal part even if the decimalChar is ','. It separates the
decimal part with ',' though, which is correct.

Is there a patch/workaround for this?

Thanks in advance,

Murat

Oops; Sorry, I must have missed your posting...

This has been broken for a while, and is is due to an overeager attempt on my part to make the code efficient. I will submit the patch to Robin directly, but for now, the fix is:

diff -u -1 -0 -r1.16 maskededit.py
--- maskededit.py 2005/04/08 21:31:25 1.16
+++ maskededit.py 2005/06/21 19:42:47
@@ -2667,28 +2667,29 @@
            # Replace up/down arrow default handling:
            # make down act like tab, up act like shift-tab:

#### dbg('Registering numeric navigation and control handlers
(if not already set)')
            if not self._keyhandlers.has_key(wx.WXK_DOWN):
                self._SetKeycodeHandler(wx.WXK_DOWN, self._OnChangeField)
            if not self._keyhandlers.has_key(wx.WXK_UP):
                self._SetKeycodeHandler(wx.WXK_UP, self._OnUpNumeric) #
(adds "shift" to up arrow, and calls _OnChangeField)

            # On ., truncate contents right of cursor to decimal point (if
any)
- # leaves cusor after decimal point if floating point, otherwise
at 0.
- if not self._keyhandlers.has_key(ord(self._decimalChar)):
+ # leaves cursor after decimal point if floating point,
otherwise at 0.
+ if not self._keyhandlers.has_key(ord(self._decimalChar)) or
self._keyhandlers[ord(self._decimalChar)] != self._OnDecimalPoint:
                self._SetKeyHandler(self._decimalChar,
self._OnDecimalPoint)
- if not self._keyhandlers.has_key(ord(self._shiftDecimalChar)):
+ + if not self._keyhandlers.has_key(ord(self._shiftDecimalChar))
or self._keyhandlers[ord(self._shiftDecimalChar)] != self._OnChangeField:
                self._SetKeyHandler(self._shiftDecimalChar,
self._OnChangeField) # (Shift-'.' == '>' on US keyboards)

            # Allow selective insert of groupchar in numbers:
- if not
self._keyhandlers.has_key(ord(self._fields[0]._groupChar)):
+ if not
self._keyhandlers.has_key(ord(self._fields[0]._groupChar)) or
self._keyhandlers[ord(self._fields[0]._groupChar)] != self._OnGroupChar:
                self._SetKeyHandler(self._fields[0]._groupChar,
self._OnGroupChar)

## dbg(indent=0, suspend=0)

    def _SetInitialValue(self, value=""):
        """
        fills the control with the generated or supplied default value.
        It will also set/reset the font if necessary and apply
        formatting to the control at this time.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org