textScrollList question

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2013   #1
textScrollList question

Hi

Is there any way I can launch a command on selected item in textScrollList when I press the enter button?

There is one for delete key and double clik, but not enter. Has anyone done it?

Thanks

F
__________________
Nothing last forever
 
Old 09 September 2013   #2
I was wondering the same thing. Anyone?
__________________

 
Old 09 September 2013   #3
Well, I don't if this can be useful for you. If you use the "selectCommand(sc)" in the textScrollList, when you press enter is executing a command. But at the same time launch the command when you select the item.

For example, in python:


def printHi():
    print "HI"


window = cmds.window( "mainWindow", title = "windowTitle")
form = cmds.formLayout(numberOfDivisions=100)

# Creating Element scroll
object = cmds.textScrollList( w=204, h=204)

cmds.textScrollList (object, e=True, a="Maya")
cmds.textScrollList (object, e=True, a="XSI")
cmds.textScrollList (object, e=True, a="MAX")

cmds.textScrollList(object, e=True,  sc = "printHi()" )

cmds.formLayout( form, edit=True, attachForm=[( object, 'top', 59), ( object, 'left', 53)] )
#=========================================

cmds.setParent( '..' )
cmds.showWindow( window )
cmds.window( "mainWindow", edit=True, widthHeight=(320.0, 320.0))

I don't know if you tried that. Let me know, if that's so, we can find another solution.

Cheers!

Last edited by JoseCuenca : 09 September 2013 at 01:05 AM.
 
Old 09 September 2013   #4
You could also make a hotkey on the return button that will execute a function you want to be done, then restore it to factory settings when the UI is closed.
 
Old 09 September 2013   #5
mmm yeap. But that may create some problems if you're working with more windows at the same time, no? I don't know, I've never tried, but to overwrite the 'enter' key... it looks like dangerous
 
Old 09 September 2013   #6
Hi jose thx for you input. i cannot use select command because everytime i go down the list with my down arrow key on my keyboard it kept running the function. But what i want is after an item is selected i hit enter to execute the function
__________________

 
Old 09 September 2013   #7
oops, sorry. I thought it was part of the same function call. Ok, Iīll have a look and Iīll let you know if I have some other solution.

 
Old 09 September 2013   #8
Hi again,

well, I donīt know exactly how you can check the enter command without overwriting the enter key as a hotkey, as said before Argiri.

The problem is, that is a bit dangerous, and I donīt think that is the best solution. Anyway, Argiri was right, itīs a way to do it. But I donīt know if you can have a lot of problems.

The point is, that usually the enter command is not override, so here I explain you a good alternative: you can use the getModifiers() function. Example:

import maya.cmds as cmds

def printHi():
    mod = cmds.getModifiers()
    if mod == 4:
        print "HI"


window = cmds.window( "mainWindow", title = "windowTitle")
form = cmds.formLayout(numberOfDivisions=100)

# Creating Element scroll
object = cmds.textScrollList( w=204, h=204)

cmds.textScrollList (object, e=True, a="Maya")
cmds.textScrollList (object, e=True, a="XSI")
cmds.textScrollList (object, e=True, a="MAX")

cmds.textScrollList(object, e=True,  sc = "printHi()" )

cmds.formLayout( form, edit=True, attachForm=[( object, 'top', 59), ( object, 'left', 53)] )
#=========================================

cmds.setParent( '..' )
cmds.showWindow( window )
cmds.window( "mainWindow", edit=True, widthHeight=(320.0, 320.0))


The getModifiers is used to check if you pressed ALT or CTRL OR SHIFT... So, if you use this in combination of the selectCommand, you can filter the action using that. So, if you press return, nothing happens, but if you press CTRL + return, then execute something.

Have a look in the Maya help, and youīll see different codes. I think that is a good way to control it. You only have to add a small text in your window saying "to execute, press Ctrl + enter"..

Well, let me know if this works for you.

Cheers!
 
Old 09 September 2013   #9
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



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 02:58 AM.


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