Lua mouseCallback() not working

Forums: Lua mouseCallback() not working
Forum for OctaneRender Lua scripting examples, discussion and support.

Lua mouseCallback() not working

Postby Mithrandir » Tue Aug 05, 2014 4:53 pm

Mithrandir Tue Aug 05, 2014 4:53 pm
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
Mithrandir
 
Posts: 12
Joined: Sun Jun 01, 2014 9:56 pm

Re: Lua mouseCallback() not working

Postby stratified » Sat Aug 09, 2014 4:55 am

stratified Sat Aug 09, 2014 4:55 am
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:

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()


cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Lua mouseCallback() not working

Postby Mithrandir » Sat Aug 09, 2014 3:06 pm

Mithrandir Sat Aug 09, 2014 3:06 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
Mithrandir
 
Posts: 12
Joined: Sun Jun 01, 2014 9:56 pm

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 1 guest

Thu Jul 02, 2020 9:32 am [ UTC ]