Search and filter button label name in maya mel

Search and filter button label name in maya mel

Anonymous
Not applicable
1,562 Views
1 Reply
Message 1 of 2

Search and filter button label name in maya mel

Anonymous
Not applicable

I am a newbie to coding, and I am trying to find a way to have a search field to filter only the buttons I want.I created an icon text button in a window and want to filter it based on button label name

 

Here is an example to show what I am trying to do.Also, all those circle label names are circleA,circleB,circleC,circleD. If I type circle, I want to show the buttons that has that name

 

search.jpg

 

I found this page that does exactly what I want but, how do I change so that it looks for label names and only show the one I typed for.Also, by default I want to show all the icons

http://melscriptingfordummies.blogspot.in/2011/02/mel-script-example-keyword-search.html

 

 

 

0 Likes
1,563 Views
1 Reply
Reply (1)
Message 2 of 2

kevin.picott
Alumni
Alumni

I'm going to guess the missing pieces based on the example you showed:

 

To show all icons by default and only add the ones you haven't filtered the easiest method is to use the "visible" flag that's on all controls. When the filter changes you get a callback that walks the entire list of buttons and enables only the matching ones.

 

For example, here's how to walk a list of buttons and match a search string called, creatively enough "searchString":

 

for( $button in $buttonList )
{
    string $label = `button $button -q -label`;
    int $visible = 0;
    if( size(`match $searchString $label`) > 0 )
    {
        $visible = 1;
    }
    button $button -edit -visible $visible;
}


Kevin "Father of the DG" Picott

Senior Principal Engineer