Page 1 of 1

mouseCallback Problems

PostPosted: Sat Aug 12, 2023 3:37 pm
by MB
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

Re: mouseCallback Problems

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

thanks

Re: mouseCallback Problems

PostPosted: Mon Aug 21, 2023 6:30 pm
by jobigoud
I just checked, you're right, only the Bitmap component implements the mouse callback.

Re: mouseCallback Problems

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

thx

Re: mouseCallback Problems

PostPosted: Wed Aug 23, 2023 9:50 am
by jobigoud
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.

Re: mouseCallback Problems

PostPosted: Wed Aug 23, 2023 12:43 pm
by MB
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.