capturing spin up/down events for wxSpinCtrl

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
vjb
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Sep 15, 2008 4:25 pm

capturing spin up/down events for wxSpinCtrl

Postby vjb » Thu Feb 11, 2016 3:26 pm

hi,

i'm using wxWidgets 2.9.5 under windows 7.

i would like to get the events EVT_SPIN_UP and EVT_SPIN_DOWN using wxSpintCtrl. on windows 7 those events are not being posted. i need to change the values by more than 1 when the user presses the arrows. if i can't use the events listed previously on windows 7 is there another way to capture the arrow press events or change by how much the spin control advances the value? is the simple solution to use a pair of wxSpinButton and wxTextCtrl?

thanks,
vince

User avatar
doublemax
Moderator
Moderator
Posts: 12822
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: capturing spin up/down events for wxSpinCtrl

Postby doublemax » Thu Feb 11, 2016 3:39 pm

What about the wxEVT_SPINCTRL event?
Use the source, Luke!

vjb
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Sep 15, 2008 4:25 pm

Re: capturing spin up/down events for wxSpinCtrl

Postby vjb » Fri Feb 12, 2016 8:59 pm

wxEVT_SPINCTRL comes after the controls have been updated. i don't see how the this event tells me if the up key has been pressed or the down key so that i can update the value based on an increment amount. i was hoping that i would not need to implement my own version of the spin control class so that i can update the spin value based on an increment amount that is greater than 1.

thanks,
vince

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 2787
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: capturing spin up/down events for wxSpinCtrl

Postby ONEEYEMAN » Tue Mar 08, 2016 3:35 pm

Hi,
Can you reproduce it in the widgets sample?
Can you try the (recently released) 3.1?

Thank you.

vjb
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Sep 15, 2008 4:25 pm

Re: capturing spin up/down events for wxSpinCtrl

Postby vjb » Tue Mar 08, 2016 6:16 pm

hi,

thank you for your response.

i did run the sample program controls w/ the same result. only OnSpinCtrl and OnSpinCtrlText were called. the two methods for the spin up/down events were not called.

i tried w/ release 3.1.0 but that also didn't work. the documentation for 3.1.1 states that the event macros for wxSpinButton may be used but not all platforms are supported. a list of supported platforms was not provided.

cheers,
vince

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 2787
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: capturing spin up/down events for wxSpinCtrl

Postby ONEEYEMAN » Tue Mar 08, 2016 6:25 pm

Hi,
Could you please file a bug at trac.wxwidgets.org about this?
Explain how this can be reproduced, state you platform, compiler and toolkit.

Also, if you modified the sample attach a patch to the sample. It will help with the reproduction and also with testing the fix.

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 12822
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: capturing spin up/down events for wxSpinCtrl

Postby doublemax » Tue Mar 08, 2016 6:33 pm

This is the code that generates the wxEVT_SPINCTRL event under Windows:

Code: Select all

void wxSpinCtrl::SendSpinUpdate(int value)
{
    wxSpinEvent event(wxEVT_SPINCTRL, GetId());
    event.SetEventObject(this);
    event.SetInt(value);

    (void)HandleWindowEvent(event);

      if ( event.IsAllowed() )
       m_oldValue = value;
}
This means that the control still has the old value and the event tells you the new value. From that you can determine the "direction". You can also see that the control does not get updated with the new value if the event is vetoed.

In conclusion: You can veto the event and change the value of the control directly as you like.
Use the source, Luke!


Return to “C++ Development”

Who is online

Users browsing this forum: Bing [Bot], dqf88 and 25 guests