wxMax - Events
BlitzMax Forums/Brucey's Modules/wxMax - Events
| ||
| Is there anywhere a list which EVENTs are supported by wxMax? And which controls react to which EVENTs. Or is someone able to point to the source files where this information could be extracted from. Peter |
| ||
| I always just dig through brucey's source to find the events. :) |
| ||
| I did now some testing with a wxDialog and the wxEVT_ENTER_WINDOW and managed to capture this event. What I like to do is do capture a mouse event (mouse click like on a button) on a wxStaticBitmap but there seems no mechanism build into wxMax that emmit events an sxStaticBitmap. -- Peter |
| ||
| Each Type in the hierarchy can capture certain events. Some are specific to a particular control, and others are more generic. wxMouseEvents should be available to most wxWindow subclasses. I checked the wxStaticBitmap source, and it looks like I've implemented event handling, so it should work (for all events available to it's parent types - like wxControl and wxWindow - as well as the mouse events). |
| ||
| Or you could use a wxBitmapButton? |
| ||
| Brucey, I tried to capture to Mouse Click Event (wxEVT_LEFT_DOWN) but as far as I can tell nothing happens.
SuperStrict
Framework wx.wxApp
Import wx.wxFrame
Import wx.wxDialog
Import wx.wxPanel
Import wx.wxStaticBitmap
Import brl.StandardIO
Type MyApp Extends wxApp
'variables
Field frame:MyFrame
' *** Methods & Functions
Method OnInit:Int()
wxImage.AddHandler(New wxPNGHandler)
' create and show the main frame
frame = MyFrame(New MyFrame.Create(Null, -1, "wxStaticBitmap Event ..
sample", ,,420, 300, wxDEFAULT_FRAME_STYLE))
frame.show()
' Connect(frame.GetID(), wxEVT_ENTER_WINDOW, enter_window)
Return True
End Method
' Function enter_window(event:wxEvent)
' Print "call: wxEVT_ENTER_WINDOW, Main Window"
' End Function
End Type
Type MyFrame Extends wxFrame
'variables
Field dialog:wxDialog
Const aaBITMAP01:Int = 100
' *** Methods & Functions
Method OnInit:Int()
'variables
Local panel:wxPanel
Local image:wxBitmap
Local bitmap:wxStaticBitmap
Local ok:Int
'code
panel = New wxPanel.Create(Self)
image:wxBitmap = New wxBitmap.Create()
ok = image.LoadFile("bd01.png", wxBITMAP_TYPE_PNG)
If ok Then
bitmap = New wxStaticBitmap.Create(panel, aaBITMAP01, image)
End If
' Connect(aaBITMAP01, wxEVT_ENTER_WINDOW, enter)
' Connect(panel.GetID(), wxEVT_ENTER_WINDOW, enter_panel)
Connect(aaBITMAP01, wxEVT_LEFT_DOWN, leftdown)
' ConnectAny(wxEVT_LEFT_DOWN, leftdown)
' Connect(panel.GetID(), wxEVT_LEFT_DOWN, leftdown_panel)
End Method
Function enter(event:wxEvent)
Print "call: wxEVT_ENTER_WINDOW, wxStaticBitmap"
End Function
Function enter_panel(event:wxEvent)
Print "call: wxEVT_ENTER_WINDOW, wxPanel"
End Function
Function leftdown(event:wxEvent)
Print "call: wxEVT_LEFT_DOWN, wxStaticBitmap"
End Function
Function leftdown_panel(event:wxEvent)
Print "call: wxEVT_LEFT_DOWN, wxPanel"
End Function
End Type
New MyApp.run()
As you can see I tried different things, but there is no reaction. Maybe I'm doing this completely wrong. At the moment I have no clue how to solve this. -- Peter |
| ||
| Try adding : Import wx.wxMouseEvent and change the Connect() to : bitmap.ConnectAny(wxEVT_LEFT_DOWN, leftdown, Null, Self) There are two ways to connect an event - depending on how certain functionality is intended to be used. The one I've posted uses what is known as an "event sink", where you Connect directly to the widget that you want to catch events for, but also pass in another widget, which "handles" the event. In the event callback function, you can use "event.sink" instead of "event.parent" to refer to the handling widget - whereas event.parent will refer to the static bitmap. I realise it is a little confusing at first, and in general you will mostly use the Connect() call as you have written it - but for Mouse capture you sometimes need to apply the Connect() directly to the child widget. The other way to avoid that, is to subclass the staticbitmap and do your Connects in your subclass's OnInit() method. Things are a little more complicated in wxWidgets world... but with that you get more control of how everything works - imo... I hope this helps a little bit. |
| ||
| Brucey, thanks for your help. I still tried it yesterday after your post and it worked. Today I reread what you wrote and thought over it some more and slowly I begin to understand how this event stuff works. -- Peter |