[Closed] Change mouse cursor outside from a dotnet listview
Hello everybody,
I know there is some examples here in the forum about how to change the mouse cursor and inside my dotnet listview it is no problem to do this also, but in my situation it doesn’t work.
I have a dotnet listview in that I have listed all materials from the scene, and I have build a function with that I can drag&drop the materials to an object. Now I want that the mouse cursor change when I start to drag the material. The best would be with the rectangle cursor what 3ds max use, but with the windows hand I am also happy.
Do you know how I can realize this?
I work on that script:
https://github.com/jb-alvarado/SearchMaterialAndMaps (but the drag and drop function I only have locally at the moment)
Thank you for helping!
jb_
Ok that is probably next “todo” task. But how to preserve “hand” cursor while draging some items outside rollout?
Ah that is a petty thing, but thank you for the information! I saw in one example where someone had this function for a label object and there it was working with changing the mouse cursor. But maybe because the rollout stay active when the mouse button is pushed.
In the drag-and-dop manager I need to make a deeper look. I was thinking it is for external files, that is way I don’t pay attention before for it.
Thank you gazybara also trying to help, also for reordering the code! I think I will use the color changing for the background, so it was not all for nothing :).
Here is a little example, maybe it illustrate my problem better:
try ( destroyDialog matList ) catch ( )
rollout matList "matList" width:200 height:300 (
local list = #()
dotNetControl lv "system.windows.forms.listView" pos:[5,5] width:190 height:290
fn doMaterialList mats = (
for i = 1 to mats.count do (
li=dotNetObject "System.Windows.Forms.ListViewItem" mats[i].name
append list li
)
lv.items.addRange list
)
on matList open do (
--Setup the forms view
lv.HeaderStyle = none
lv.columns.add "" 180
lv.view = ( dotNetClass "system.windows.forms.view" ).details
doMaterialList sceneMaterials
)
on lv mousemove do (
cursors = dotNetClass "System.Windows.Forms.Cursors"
cursor = dotNetClass "System.Windows.Forms.Cursor"
cursor.current = cursors.hand
)
)
createDialog matList
You see there that inside the listview the mouse cursor change to a hand. But I need a function that change the mouse cursor when I drag a item outside the listview.
There is a command called “on ItemDrag […] do”, this I use in my original script, but it don’t change the mouse icon.
Thanks gazybara for yous answer!
It only work so long as I don’t move the mouse. I think I try already all mouse events. The most of them only start one time a command and I think I need something what call the command so long as I push the mouse button, or move the mouse.
Probably there is some hack for this. I tried with timer control but still nothing
At least I organize your code a bit
try(destroyDialog ::matList)catch()
rollout matList "matList"
(
local list = #()
fn defClr r g b = ((dotNetClass "System.Drawing.Color").FromArgb r g b)
local crs = (dotnetclass "Cursors").hand
fn doMaterialList lv mats =
(
list = for i = 1 to mats.count collect
(
li = dotNetObject "ListViewItem" mats[i].name
li.forecolor = defClr 200 200 200
li.backcolor = if mod i 2 != 0 then defClr 60 60 60 else defClr 80 80 80
li
) ; lv.items.addRange list
)
timer clock "" interval:10 active:off
dotNetControl lv "ListView" pos:[5,5] width:190 height:290
on clock tick do (if lv.focused do lv.cursor = crs)
on matList open do
(
--Setup the forms view
lv.HeaderStyle = none
lv.columns.add "" 180
lv.allowdrop = lv.AllowColumnReorder = on
lv.backcolor = defClr 60 60 60
lv.view = (dotNetClass "View").details
doMaterialList lv meditmaterials --sceneMaterials
)
on lv mousedown arg do clock.active = on
--on lv ItemDrag arg do clock.active = on
on lv mouseup arg do
(
clock.active = off ; lv.cursor = (dotnetclass "Cursors").arrow
)
)
createDialog matList 200 300 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)