Andre Arpin <ar...@kingston.net> wrote: (30/12/2010 15:47) >> If you have an equally neat trick to solve the spinctrl's habit of replacing >text with the internal numeric >> value every time I hit the MAX or MIN limit, please show me. This is by far >the more serious problem because >> the internal handling updates the display but does not send a signal! That >means there is likely no simple >> way to prevent it doing this, except to detect any click as you showed in >the first mail. >> > >---try this code you may it useful >---I use long name so I do need to comment (I am terrible at it) > >-- The fucntion GoingUp return the current control so only two functions are >-- needed for the up and down > >frame = wx.wxFrame(wx.NULL, wx.wxID_ANY,'Test spin control') >frame:Show(true) >globalSpinControl=wx.wxSpinCtrl(frame) >globalSpinControl:SetRange(10,40) > >local function GoingUp(event) > local SpinCntrl = event:GetEventObject():DynamicCast('wxSpinCtrl') > local mouseY, spRect = event:GetPosition().Y, SpinCntrl:GetRect() > return event:GetEventObject():DynamicCast('wxSpinCtrl'), mouseY < >spRect.Top + spRect.Height / 2 >end > >local theValue = 0 > >local MOUSE_DOWN = > function (event) > print('in EVT_LEFT_DOWN') > local localSpinControl, Up = GoingUp(event) > theValue = localSpinControl.Value > print(localSpinControl.Value, 'before') > event:Skip() > print(localSpinControl.Value, 'after') > end > >local MOUSE_UP = > function (event) > print('in EVT_LEFT_UP') > local localSpinControl, Up = GoingUp(event) > local highHit, lowHit = false, false > print('theValue:'..theValue, 'GoingUp? : ' , Up) > print(localSpinControl.Value, 'before') > event:Skip() > print(localSpinControl.Value, 'after') >--[[ localSpinControl.Value = 16 -- set the value here to what you >want]] > if Up then > highHit = theValue == localSpinControl.Max > else > lowHit = theValue == localSpinControl.Min > end > print('highHit: '..tostring(highHit), 'lowHit: '..tostring(lowHit)) > end > >globalSpinControl:Connect(wx.wxEVT_LEFT_UP, MOUSE_UP) >globalSpinControl:Connect(wx.wxEVT_LEFT_DOWN, MOUSE_DOWN) > >wx.wxGetApp():MainLoop() > >A problem with this code is that if you hold the mouse down on a button it >does not report a hi or lot hit properly. > >so maybe > highHit = theValue == localSpinControl.Max or > localSpinControl.Max == localSpinControl.Value > > >would be a better test > > >Andre >Happy new year >
Thankyou. That did so many odd things that I don't know what to do with it. :) Nice to see a fully worked example though, snippets don't always work, full examples do, I wish they happened more often. :) While I can do the area detection (already had to in some other project), this is not really the answer. As you see, it takes a lot of ectra code. It doesn't stop there either, I have to handle arrow keys, mouse scrolls, maybe even more stuff, just to get a Spinctrl to work as it used to with NONE of this extra code! One thing I found was an UpdateUI event or some such. It forced update at all times though, so it is a vicious cycle that detects its own updates, updates again, chewing as much of my CPU time as ti can get a hold of. :) If I could find somethingsimilar but a tad less trigger-happy it might solve this yet. ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users