Search code examples
c++user-interfacewxwidgetscodeblocks

Connect mouse event to wxStaticBitmap (wx 2.8)


Hi guys I am here to beat dead horse..

Basically what I am doing is assigning stuff onto a map.

The map: A wxStaticBitmap object with the background uploaded by user The bomb(lol): A wxStaticBitmap object

I managed to merge bomb into arbitrary position on map now with wxMemoryDC + wxDC.

However,I am totally stuck with setting "bomb" with mouse.I want to click somewhere on the map and somehow the bomb will be dropped at the very position I just clicked.

I took a stab with wxMouseEvent and EVT_MOTION(well,like macro ones declared on top) Obviously they only work with wxWindow or wxFrame.

I was wondering how I am gonna bind mouse event to staticbitmap probably by Connect() but I did not find a proper usage regarding to bomb assignment...


Solution

  • In general, it is best to create a single wxPanel as the child of the frame, then create all your widgets as children of the wxPanel. This way most everything works as you naturally expect and you hit fewer gotchas.