[Closed] ProBoolean and it's Undo
The only way I found to create an Undo entry when changing the selection is by clicking in the ListBox.
Also, I found that you need to have one item before this to work.
So in the code I posted before, I first select the only item the Listbox have, then send a mouse down/up message. Then modify the selection and just send the mouse down/up again.
I suppose a message with a mouse down/up is all it needs in order to work, as the selection is already being made with the SetOperandSel() function. So sending a 0 as parameter just trigger the action in a corner of the Listbox and the plugin takes care of what items are selected every time it receives those messages.
I haven’t tried with more objects and multiple selection tough.
I’ve tried .
I’ve found that I have to hit the item that corresponds to just added one.
You people have to understand the problem…
Some day making a tool for extending the ProBoolean functionality you will meet a screwed Undo functionality.
I and Jorge are just trying to help you there.
Some progress made. The dam comfusing thing was caused by a redraw issue.
So, here is what I figure out and seems to work.
- Send a Mouse Down/Up message after setting the operands (not before).
- Set the state of the selected Operands
- Redraw the ListBox. This is a visual issue, internally the selection is correct.
Almost all can also be done without sending messages, but there are issues with the last added item.
/* CREATE TEST OBJECTS --------------------- */
delete objects
b = box wirecolor:red
c1 = cylinder pos:[18,0,0] wirecolor:blue
c2 = cylinder pos:[-18,0,0] wirecolor:blue
c3 = cylinder pos:[0,18,0] wirecolor:yellow
c4 = cylinder pos:[0,-18,0] wirecolor:yellow
ProBoolean.SetOperandA b
select b
gc()
/* ----------------------------------------- */
fn GetProBooleanListboxHWND =
(
getID = uiaccessor.getwindowresourceid
children = windows.getchildrenhwnd #max
-- ID 1042 from Max 2011 to Max 2017
for j in children where j[4] == "ListBox" and getID j[1] == 1042 do return j[1]
return undefined
)
(
max modify mode
WM_LBUTTONDOWN = 0x0201
WM_LBUTTONUP = 0x0202
listHWND = GetProBooleanListboxHWND()
if listHWND != undefined then
(
theHold.Cancel()
theHold.SuperBegin()
ProBoolean.SetBoolOp b 4
ProBoolean.SetOperandB b c1 2 1
ProBoolean.SetOperandB b c2 2 1
ProBoolean.SetOperandB b c3 2 1
ProBoolean.SetOperandB b c4 2 1
windows.sendMessage listHWND WM_LBUTTONDOWN 0 0
windows.sendMessage listHWND WM_LBUTTONUP 0 0
ProBoolean.SetOperandSel b 0 on
ProBoolean.SetOperandSel b 1 off
ProBoolean.SetOperandSel b 2 off
ProBoolean.SetOperandSel b 3 on
ProBoolean.SetOperandSel b 4 on
-- Workaround
-- Can't find a message to redraw the listbox
modpanel.setcurrentobject b
theHold.SuperAccept "Add B"
)else(
messagebox "No HWND. Do a better job next time"
)
)
you can redraw the panel with:
modpanel.setcurrentobject b
suspendediting()
resumeEditing()
it does do more than just redraw. it suspends and resumes some messages sent to the panel
we are working with example only. in real life it can be a proboolean object in any position in the modifier stack. so just selecting is not correct because it always sets current modified object as top in the stack. we want to keep it to our proboolean object.
Ok, changed it to “modpanel.setcurrentobject b”
Perhaps there are other ways?
It is hard to get the ListBox to refresh.
i think it needs more than just a control redraw. it seems like not all internal data updated…
as another option you cam simulate “click ‘Result’” radiobutton. it has to update the operand list
Yes I already tested them and some radiobuttons also trigger the refresh, as well as changing the panel to create or other and back to modify. In order to send a message to a radiobutton, you also need to identify it first and get the handle.
I was actually looking for the most efficient way of doing it.
Other thing that forces a refresh is pin/unpin the modifier, but needs to be done manually. So there are many ways of doing it.
As far as I could test it is just a redraw/refresh issue.
If you don’t issue any redraw, you can get the selection state of the operands via script and see they are already correct.
But I didn’t test all the posibilities, so I might missed something for sure. You are working with it, so you will for sure have better examples to test.
If you find any specific issue please post it so I can try it on my end and see if we can get a working approach.