Hi,
I've been trying to use the mouseCallback() function which is supposedly available in the API but with no success. While the regular button and text editor component callbacks are easily handled, nothing happens with mouseCallback. Anyone know how to do this?
Much obliged
-Mtl
Lua mouseCallback() not working
- stratified
- Posts: 945
- Joined: Wed Aug 15, 2012 6:32 am
- Location: Auckland, New Zealand
Hi Mithrandir,
I think it only works with the bitmap component. I don't remember why it doesn't work with other components (might be a bug). I will look into it. This example should work:
cheers,
Thomas
I think it only works with the bitmap component. I don't remember why it doesn't work with other components (might be a bug). I will look into it. This example should work:
Code: Select all
-- mouse handler example
local bitmap = octane.gui.create
{
type = octane.gui.componentType.BITMAP,
width = 400,
height = 200,
mouseCallback = function(component, event, x, y, sx, sy)
print(string.format("event %d @ position { %d, %d })", event, x, y))
end
}
local window = octane.gui.create
{
type = octane.gui.componentType.WINDOW,
width = 500,
height = 500,
text = "Mouse Test",
children = { bitmap },
mouseCallback = function(event, x, y)
print("this seems to be broken!")
end
}
window:showWindow()
Thomas
- Mithrandir
- Posts: 12
- Joined: Sun Jun 01, 2014 9:56 pm
Thank you Thomas,
Certainly opens possibilities for using bitmaps. Although, if not a bug with the other components, then mouseCallback() should be removed from the documentation showing it as one of their methods.
It would be good if it worked for text editor so that action could be taken when clicking on a field. Right now, no callback action takes place until a character is entered. If mouse callbacks can't be used here, the an on_enter and on_exit callback would make coding and error handling much easier.
Again, thanks
-Mtl
Certainly opens possibilities for using bitmaps. Although, if not a bug with the other components, then mouseCallback() should be removed from the documentation showing it as one of their methods.
It would be good if it worked for text editor so that action could be taken when clicking on a field. Right now, no callback action takes place until a character is entered. If mouse callbacks can't be used here, the an on_enter and on_exit callback would make coding and error handling much easier.
Again, thanks
-Mtl