- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, folks.
I'm trying to show stuff when cursor is over spinner buttons and hide it when cursor is out. Since native max spinner doesn't have these events, I'm using dotnet. For simplicity, spinner's color will serve as "stuff".
First iteration. Kind of almost works, but cursor has to be precisely on spinner's border to change color. As soon as it moves in or outside, color is set back to default.
try(destroyDialog myRollout) catch()
(
rollout myRollout "spinnerTest" (
dotNetControl spinner "System.Windows.Forms.NumericUpDown" pos:[10,50] width:100
on spinner MouseEnter senderArg arg do (
spinner.BackColor = (dotNetClass "System.Drawing.Color").Yellow
)
on spinner MouseLeave senderArg arg do (
spinner.BackColor = (dotNetClass "System.Drawing.Color").White
)
)
createDialog myRollout 150 150
)
Decided to add handlers to child controls instead. And here it gets weird. Well, weirder.
Field behaves as expected - enter and leave will change color. But UpDown buttons seem to never generate Leave event.
try(destroyDialog myRollout) catch()
(
local myEnter, myLeave
rollout myRollout "spinnerTest" (
dotNetControl spinner "System.Windows.Forms.NumericUpDown" pos:[10,50] width:100
on myRollout open do (
local childControl0 = myRollout.spinner.Controls.Item[0]
local childControl1 = myRollout.spinner.Controls.Item[1]
dotNet.addEventHandler childControl0 "MouseEnter" myEnter
dotNet.addEventHandler childControl0 "MouseLeave" myLeave
dotNet.addEventHandler childControl1 "MouseEnter" myEnter
dotNet.addEventHandler childControl1 "MouseLeave" myLeave
)
)
fn myEnter = (
myRollout.spinner.BackColor = (dotNetClass "System.Drawing.Color").Yellow
)
fn myLeave = (
myRollout.spinner.BackColor = (dotNetClass "System.Drawing.Color").White
)
createDialog myRollout 150 150
)
So now my idea is to start with no handlers for spinner and only mouseEnter for UpDown buttons.
When cursor enters UpDown I will change color and add mouseLeave handler for spinner.
Leave function will change color back to default and remove handler from spinner.
This thing doesn't work at all 8(
It throws error "Unable to convert: dotNetControl:spinner:System.Windows.Forms.NumericUpDown to type: dotNetObject"
try(destroyDialog myRollout) catch()
(
local myEnter, myLeave
rollout myRollout "spinnerTest" (
dotNetControl spinner "System.Windows.Forms.NumericUpDown" pos:[10,50] width:100
on myRollout open do (
local childControl0 = myRollout.spinner.Controls.Item[0]
local childControl1 = myRollout.spinner.Controls.Item[1]
dotNet.addEventHandler childControl0 "MouseEnter" myEnter
dotNet.addEventHandler childControl1 "MouseEnter" myEnter
)
)
fn myLeave = (
myRollout.spinner.BackColor = (dotNetClass "System.Drawing.Color").White
dotNet.removeAllEventHandlers myRollout.spinner
)
fn myEnter = (
myRollout.spinner.BackColor = (dotNetClass "System.Drawing.Color").Yellow
dotNet.addEventHandler myRollout.spinner "MouseLeave" myLeave
)
createDialog myRollout 150 150
)
The question is: how can I handle spinner as dotNetObject instead of dotNetControl?
Or maybe there is no need for this and everything can be fixed at very first step with some flag that allows parent control to properly generate enter/leave events? Hm, in this case I would like to learn both: the easy fix and how to solve object/control issue.
Solved! Go to Solution.