CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 11-05-2013, 11:48 AM   #1
Mossen
New Member
 
Mossen's Avatar
portfolio
Christoffer Söderberg
Research & Development
Älmhult, Sweden
 
Join Date: Nov 2013
Posts: 5
dotNet Keyboard focus, control keyboard

Hi this is my first post on this forums so I will try to make this post as good as possible

I'm trying to create an dotNet interface overlay in 3ds max with the possibility to do keyboardshortcuts or using a searchfield for example. But what ever I do max wont let go of the keyboard focus, i've tried several different methods like:

form = dotNetObject "form"
form.focus() --only brings form to the front and not the keyboard focus

dnKeyboard = dotNetObject "system.windows.Forms.Control"
keyboard.focus() -- which always returns false


Then there are several methods that actually do work, I will also explain why I don't want to use these:

--this is the best one I've found so far since it does what I want but with activeXcontroler help, which is something I would like to avoid for compatibility issues in the future.
--But this one actually work with out any issus in dotNet right now.
enableAccelerators = false --write this when you want to have control
enableAccelerators = true --and this when your script is done

simple example script:
--dotNet interface
form = dotNetObject "form"
dnKeyboard = dotNetObject "system.windows.Forms.Control"
form.show()

--DotNet function
fn KeyPressed senderArg keyPressEventArgs =
(print (keyPressEventArgs.KeyData))
dotnet.addEventHandler form "KeyUp" KeyPressed

--activeX controller
--Fixing the problem but isn't the nicest solution.
--Run it one more time to giva back controll to max

if (enableAccelerators) then (enableAccelerators = false) else (enableAccelerators = true)







another solution that (kind of)works is to use a regular max rollout, with this solution you for starters get the max rollout which would not work for what I have intended to do, but also a window that constantly must be at the top:

rollout example "example" width:398 height:224
(
timer theTicker interval:15 active:true
dotNetControl dnControl "System.Windows.Forms.Control"
local dnKeyboard = DotNetClass "System.Windows.Forms.Keys"
Local KeyPressed

on theTicker tick do (
dnControl.focus() --sets focus
)

on dnControl KeyDown senderArg keyPressEventArgs do
(
KeyPressed = keyPressEventArgs.keyCode
keyPressEventArgs.SuppressKeyPress = true
print KeyPressed
)

on dnKeys KeyUp senderArg keyPressEventArgs do
(
KeyPressed = undefined
)
)
createDialog example


I hope these solutions can help someone else at least and If anyone has a better solution to my problem please write it below^^
//Christoffer
 
Old 11-11-2013, 09:10 AM   #2
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,827
you should register to the gotFocus and lostFocus events of your control and enable/disable max accelerators accordingly.
 
Old 11-12-2013, 10:15 AM   #3
try2script
Expert
portfolio
Mike
Moldova
 
Join Date: Mar 2013
Posts: 484
Quote:
Originally Posted by lo
you should register to the gotFocus and lostFocus events of your control and enable/disable max accelerators accordingly.


It's very interesting! I would like to see how to do it!
 
Old 11-12-2013, 11:23 AM   #4
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,331
Send a message via ICQ to denisT
Quote:
Originally Posted by try2script
It's very interesting! I would like to see how to do it!

there is tons of samples about this subject on this forum. just search for enableAccelerators
 
Old 11-19-2013, 09:54 AM   #5
Mossen
New Member
 
Mossen's Avatar
portfolio
Christoffer Söderberg
Research & Development
Älmhult, Sweden
 
Join Date: Nov 2013
Posts: 5
well in my example in the first post I use the function enableAccelerators, but since It's an old function and based upon Active X I'm not sure that it's a good idea to use it since Microsoft isn't including that package anymore with windows.

But maybe that's the only way right now to control this in Max?

also here is the documentation page for enableAccelerators
http://docs.autodesk.com/3DSMAX/15/...mber=d30e648360
 
Old 11-20-2013, 08:51 AM   #6
Mossen
New Member
 
Mossen's Avatar
portfolio
Christoffer Söderberg
Research & Development
Älmhult, Sweden
 
Join Date: Nov 2013
Posts: 5
Yeah this is the method I used as an example in the first post, but since it's part of activeX and Microsoft isn't including that in windows anymore It doesn't seem as the best method to use for this. But maybe there isn't another way right now?
 
Old 11-20-2013, 09:21 AM   #7
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,827
What does it have to do with ActiveX? It's just a part of the 3dsmax UI message loop.
 
Old 11-21-2013, 08:53 AM   #8
Mossen
New Member
 
Mossen's Avatar
portfolio
Christoffer Söderberg
Research & Development
Älmhult, Sweden
 
Join Date: Nov 2013
Posts: 5
Quote:
Originally Posted by lo
What does it have to do with ActiveX? It's just a part of the 3dsmax UI message loop.


well allot according to the maxscript guide:
http://docs.autodesk.com/3DSMAX/15/...mber=d30e648360
AMAXScript system global called "enableAccelerators" can be set to false whenever an ActiveX control gets focus so that the user can type in the controls.
 
Old 11-21-2013, 08:56 AM   #9
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,827
That doesn't say accelerators are part of ActiveX.
It says that when you use an activeX control, you should disable accelerators so they don't interfere with keyboard input to ActiveX controls ... or for that matter, any non-max controls, such as dotnet controls.
 
Old 11-22-2013, 07:27 AM   #10
Mossen
New Member
 
Mossen's Avatar
portfolio
Christoffer Söderberg
Research & Development
Älmhult, Sweden
 
Join Date: Nov 2013
Posts: 5
ah.. that's true^^

well in that case the problem was solved from the beginning, I just din't realize it...
Thanks for the clarification!
 
Old 11-22-2013, 07:27 AM   #11
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 01:35 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.