itsols
itsols

Reputation: 5582

wxButton - change position using C++

I'm doing some experimental coding on Code::Blocks with wxSmith.

I have 2 buttons. When one is clicked, I want to change the position of the other.

I've tried this:

void FormButtons::OncmdMoveClick(wxCommandEvent& event)
{
    cmd.pos.x += 10;
}

But I think it's not correct. According to the docs, I am supposed to be able to access wxPoint->X but I'm not quite sure how this is achieved.

Thanks for any tips.

EDIT: Sorry for the lack of info. cmd and cmdMove are wxButton.

Upvotes: 0

Views: 1191

Answers (2)

itsols
itsols

Reputation: 5582

STRANGELY, I could not find sufficient info on the docs. Perhaps I'm overlooking something. But in the mean time, I bumped into this article that is about Python and I did a bit of guess-work and came up with this method...

cmd->SetPosition( wxPoint( cmd->GetPosition().x + 10,100));

It works great and does what I need. But I find the answer by ravenspoint to be easier. I wonder how we can find out the methods of an object/class when we don't have any docs on them. Also my Code::Blocks IDE does not give any support on it. At least an object/class browser would be super-helpful :)

Upvotes: -1

ravenspoint
ravenspoint

Reputation: 20457

It seems odd that you have a reference to a widget - usually you have a pointer.

Anyhow, you need to move the button by calling a method called, strangely enough, Move.

http://docs.wxwidgets.org/trunk/classwx_window.html#ab1cb98c8d25b9e6ff7b706b1446c3df7

Upvotes: 4

Related Questions