mouseCallback Problems

Forums: mouseCallback Problems
Forum for OctaneRender Lua scripting examples, discussion and support.

mouseCallback Problems

Postby MB » Sat Aug 12, 2023 3:37 pm

MB Sat Aug 12, 2023 3:37 pm
I would like to use a mouseCallback with a numeric box control. The callback function is listed as a property in PROPS_NUMERIC_BOX, but I can't get it to work.
Infact the only control I can get a mouseCallback to work with is a bitmap. Since I can get it to work with that, I feel I do understand how it should work.
Does the api documentation imply mouseCallbacks work with a bunch of controls that actually don't support this. Code below.

Thanks for your help.
Mark

-- Hookup the callbacks with all the GUI elements
btnFileOpen:updateProperties { callback = guiCallback }
chkDiffuseMaterial:updateProperties { callback = guiCallback }
chkGlossyMaterial:updateProperties { callback = guiCallback }
chkSpecularMaterial:updateProperties { callback = guiCallback }
chkMetallicMaterial:updateProperties { callback = guiCallback }
btnProcessFile:updateProperties { callback = guiCallback }
btnTint:updateProperties { callback = guiCallback }
clsTintColorPicker:updateProperties { callback = guiCallback }
btnTintOk:updateProperties { callback = guiCallback }
btnTintApply:updateProperties { callback = guiCallback }
btnTintCancel:updateProperties { callback = guiCallback }
nbxSpecularRadius:updateProperties { callback = guiCallback }
nbxNormalAmount:updateProperties { callback = guiCallback }
--nbxDisplacementContrast:updateProperties { callback = guiCallback }
--nbxSpecularBrightness:updateProperties { callback = guiCallback }
btnReplacePixel:updateProperties { callback = guiCallback, mouseCallback = mouseCallback }
btnHelp:updateProperties { callback = guiCallback }
btnHelpClose:updateProperties { callback = guiCallback }
btnMainClose:updateProperties { callback = guiCallback }

nbxDisplacementContrast:updateProperties {mouseCallback = mouseCallback }
nbxSpecularBrightness:updateProperties {mouseCallback = mouseCallback }
picDisplacementMap:updateProperties {mouseCallback = mouseCallback }
btnReplacePixel:updateProperties {mouseCallback = mouseCallback }


-- The mouseCallback function, bitmaps work, all others don't

function mouseCallback(component, event)

--print("@mouseCallback", component, event)

if component == nbxDisplacementContrast then

print("@nbxDisplacementContrast mouse events")

if event == octane.gui.eventType.MOUSE_UP or event == octane.gui.eventType.MOUSE_DRAG then

print(" Component, Event =", component, event)
octane.gui.dispatchGuiEvents(400)
setDisplacementMapContrast(nbxDisplacementContrast.value)


end


elseif component == nbxSpecularBrightness then

print("@nbxSpecularBrightness mouse events")

if event == octane.gui.eventType.MOUSE_UP or event == octane.gui.eventType.MOUSE_DRAG then

print(" Component, Event =", component, event)
octane.gui.dispatchGuiEvents(400)
setSpecularMapBrightness(nbxSpecularBrightness.value)


end



elseif component == btnReplacePixel then

print("@btnReplacePixel mouse events")

if event == octane.gui.eventType.MOUSE_DOWN then --or event == octane.gui.eventType.MOUSE_DRAG then

print(" Button Mouse Down")
--Get the pixel color
octane.gui.dispatchGuiEvents(400)
--setSpecularMapBrightness(nbxSpecularBrightness.value)


end

if event == octane.gui.eventType.MOUSE_UP then --or event == octane.gui.eventType.MOUSE_DRAG then

print(" Button Mouse Up")
--Get the pixel color
octane.gui.dispatchGuiEvents(400)
--setSpecularMapBrightness(nbxSpecularBrightness.value)


end



elseif component == picDisplacementMap then

--print("@picDisplacementMap mouse events")

if event == octane.gui.eventType.MOUSE_DOWN then --or event == octane.gui.eventType.MOUSE_DRAG then

print(" Mouse Down")
--Get the pixel color
octane.gui.dispatchGuiEvents(400)
--setDisplacementContrast(nbxDisplacementContrast.value)


end


if event == octane.gui.eventType.MOUSE_UP then --or event == octane.gui.eventType.MOUSE_DRAG then

print(" Mouse Up")
--Get the pixel color
octane.gui.dispatchGuiEvents(400)
--setSpecularMapBrightness(nbxSpecularBrightness.value)


end


end


end
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Re: mouseCallback Problems

Postby MB » Wed Aug 16, 2023 5:04 pm

MB Wed Aug 16, 2023 5:04 pm
Can someone from Otoy weigh in here?

thanks
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Re: mouseCallback Problems

Postby jobigoud » Mon Aug 21, 2023 6:30 pm

jobigoud Mon Aug 21, 2023 6:30 pm
I just checked, you're right, only the Bitmap component implements the mouse callback.
User avatar
jobigoud
OctaneRender Team
OctaneRender Team
 
Posts: 230
Joined: Sat Aug 15, 2015 1:28 pm

Re: mouseCallback Problems

Postby MB » Tue Aug 22, 2023 10:33 pm

MB Tue Aug 22, 2023 10:33 pm
Hopefully it will be fixed at some point. Slider controls strike me as the priority.

thx
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Re: mouseCallback Problems

Postby jobigoud » Wed Aug 23, 2023 9:50 am

jobigoud Wed Aug 23, 2023 9:50 am
Can you describe the use case more? Is it for mouse enter/leave? If mouse wheel doesn't trigger a value change I think that's a different problem.
For a bare bitmap control these events are important to add interactivity but on the other controls the interactivity is already built-in.
User avatar
jobigoud
OctaneRender Team
OctaneRender Team
 
Posts: 230
Joined: Sat Aug 15, 2015 1:28 pm

Re: mouseCallback Problems

Postby MB » Wed Aug 23, 2023 12:43 pm

MB Wed Aug 23, 2023 12:43 pm
Simple use case

On a slider, or a numeric box with slider active, I would like to trigger an event that updates the app, in this case the contrast of an image in bitmap, (I have others)
utilizing the new slider value on the slider's non-existent mouse up event. In my case it saves having an apply button on the form, and it avoids too much activity.
if it's attached to a value change event. I tried it with value change, and it stacks all the values in a que and applies the contrast algorithm dozens of times to the image which is not good. If i could flush that stack I could work around it.

I recognize there are numerous controls that it does not make sense to have mouse events, a button for instance.
mouse down)
See below, each image can be manipulated before building an orbx material, but I don't want an apply button for each, just update when releasing a slider.

While I'm on this topic, I would like to be apple to zoom to fit these images into the bitmap control, can I do this, at the moment the user only gets
to see the top left image of the diffuse map they import, and likewise with the others that are generated by the script.

ImageToMaterial.png
Note the 4 bitmap controls and the 3 slider controls used to tweek the normal, displacement and specular maps.
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 33 guests

Sat Apr 27, 2024 3:10 pm [ UTC ]