Notifications
Clear all
[Closed] Setting focus to viewport
May 02, 2008 11:13 pm
Is there a way to set focus to the viewport after executing a script? I’m having an issue after i run a collect and select script where after i run it, i’m allowed to navigate through a scene, but keyboard short cuts aren’t working.
Example, i collect all the boxes in the scene using a collection line, and then select them. I am allowed to navigate through the scene, but i'm not able to switch to wireframe mode etc, or zoom in on selected.
The only way i've been able to solve this problem is clicking in the viewport, which usually makes me lose the items i've just selected.
Here's the code i am using, if it also helps, i'm running Draster's switcher as well.
(
global CollectRollout
try( destroyDialog CollectRollout)catch ()
rollout CollectRollout ""
(
edittext CollectBoxText fieldWidth:120 offset:[0,10]
groupBox CollectGroup "search" pos:[5,0] width: 145 height:40
button CloseButton "x" pos:[160, 2] width:14 height:14
on CloseButton pressed do DestroyDialog CollectRollout
on CollectBoxText entered txt do
(
if txt != "" do
(
clearSelection()
with undo on
(
MultipleNodes = for o in objects where matchpattern o.name pattern:("*"+CollectBoxText.text+"*") collect o
select MultipleNodes
CollectBoxText.text = ""
);
)
);
)
createdialog CollectRollout pos:[38,1003] width:175 height:40 align:#left style:#( #style_sysmenu,#style_resizing) modal:false escapeEnable:true lockHeight:true lockWidth:true
)
Has any one else come across this problem?
.
3 Replies
May 02, 2008 11:13 pm
viewport.activeviewport = N
Sets the active viewport to the Nth view, but whether that restores hotkey usage as well…
May 02, 2008 11:13 pm
It appears that i have to simulate a right click, then a left click in order to get my keyboard shortcut’s back.
I have this code from dotNet given to me by a friend, excuse my ignorance, but how would i incoporate it into my MXS?
public class MakeAClick{
[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll", SetLastError=true)]
public static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 cButtons, UInt32 dwExtraInfo)
[Flags]
public enum MouseEventFlags
{
LEFTDOWN = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
}
SetCursorPos(10, 50);
MakeAClick.mouse_event((uint)MouseEventFlags.RIGHTDOWN,0,0,0,0);
MakeAClick.mouse_event((uint)MouseEventFlags.RIGHTUP,0,0,0,0);
MakeAClick.mouse_event((uint)MouseEventFlags.LEFTDOWN,0,0,0,0);
MakeAClick.mouse_event((uint)MouseEventFlags.LEFTUP,0,0,0,0);