Generating events for wxSpinButton Topic is solved

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.
Post Reply
asandler
In need of some credit
In need of some credit
Posts: 6
Joined: Sat Jul 26, 2008 7:41 am

Generating events for wxSpinButton

Post by asandler » Fri Aug 08, 2008 7:24 pm

Anyone knows how to simulate press on a spin button? What event I should send to it and how?
Thanks.
Alex.

benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Re: Generating events for wxSpinButton

Post by benedicte » Thu Aug 14, 2008 9:04 am

asandler wrote:Anyone knows how to simulate press on a spin button? What event I should send to it and how?
Thanks.
Alex.
Did you try to have al look at wxSpinEvent, as described in the wxWidgets documentation ?

Herebelow is a sample of user code sending a "command" event

Code: Select all

void MyWindow::SendEvent()
{
    wxCommandEvent event( wxEVT_MY_EVENT, GetId() );
    event.SetEventObject( this );
    // Give it some contents
    event.SetText( wxT("Hallo") );
    // Send it
    GetEventHandler()->ProcessEvent( event );
}
taken from the "event handling overview" help section.

Just replace the event object class to get your need.

asandler
In need of some credit
In need of some credit
Posts: 6
Joined: Sat Jul 26, 2008 7:41 am

Post by asandler » Thu Aug 14, 2008 9:16 am

Here's the problem. In MSW wxSpinButton implemented using built into windows control. I.e. windows control holds the counter for the spin button. So when you send event to wxWidgets spin button it will not do anything.

What you have to do is to send event to windows control. Yet you cannot do this in platform independent manner. The only solution for this problem is to sub-class wxSpinButton and do private implementation of the value calculations. This includes what happens when you press and hold one of the control buttons.

Anyway, thanks a lot for trying to help. Unfortunately this issue seems to be unsolvable at the moment.

Post Reply