------------------------------------------------------------------------------
| 766 | |
| 767 | //------------------------------------------------------------------------------ |
| 768 | void GuiPopUpMenuCtrl::setSelected(S32 id, bool bNotifyScript ) |
| 769 | { |
| 770 | for( S32 i = 0; i < mEntries.size(); i++ ) |
| 771 | { |
| 772 | if( id == mEntries[i].id ) |
| 773 | { |
| 774 | i = ( mRevNum > i ) ? mRevNum - i : i; |
| 775 | mSelIndex = i; |
| 776 | |
| 777 | if( mReplaceText ) // Only change the displayed text if appropriate. |
| 778 | setText( mEntries[ i ].buf ); |
| 779 | |
| 780 | // Now perform the popup action: |
| 781 | |
| 782 | if( bNotifyScript ) |
| 783 | { |
| 784 | if( isMethod( "onSelect" ) ) |
| 785 | Con::executef( this, "onSelect", Con::getIntArg( mEntries[ mSelIndex ].id ), mEntries[mSelIndex].buf ); |
| 786 | |
| 787 | execConsoleCallback(); |
| 788 | } |
| 789 | |
| 790 | return; |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | if( mReplaceText ) // Only change the displayed text if appropriate. |
| 795 | { |
| 796 | setText(""); |
| 797 | } |
| 798 | mSelIndex = -1; |
| 799 | |
| 800 | if( bNotifyScript && isMethod( "onCancel" ) ) |
| 801 | Con::executef( this, "onCancel" ); |
| 802 | |
| 803 | if( id == -1 ) |
| 804 | return; |
| 805 | |
| 806 | // Execute the popup console command: |
| 807 | if( bNotifyScript ) |
| 808 | execConsoleCallback(); |
| 809 | } |
| 810 | |
| 811 | //------------------------------------------------------------------------------ |
| 812 | // Added to set the first item as selected. |