------------------------------------------------------------------------------
| 1145 | |
| 1146 | //------------------------------------------------------------------------------ |
| 1147 | void GuiPopUpMenuCtrl::closePopUp() |
| 1148 | { |
| 1149 | if ( !mInAction ) |
| 1150 | return; |
| 1151 | |
| 1152 | // Get the selection from the text list: |
| 1153 | |
| 1154 | if( !mBackgroundCancel ) |
| 1155 | { |
| 1156 | mSelIndex = mTl->getSelectedCell().y; |
| 1157 | mSelIndex = ( mRevNum >= mSelIndex && mSelIndex != -1 ) ? mRevNum - mSelIndex : mSelIndex; |
| 1158 | if ( mSelIndex != -1 ) |
| 1159 | { |
| 1160 | if ( mReplaceText ) |
| 1161 | setText( mEntries[mSelIndex].buf ); |
| 1162 | setIntVariable( mEntries[mSelIndex].id ); |
| 1163 | } |
| 1164 | } |
| 1165 | |
| 1166 | // Release the mouse: |
| 1167 | mInAction = false; |
| 1168 | mTl->mouseUnlock(); |
| 1169 | |
| 1170 | // Now perform the popup action: |
| 1171 | if( mSelIndex != -1 && !mBackgroundCancel ) |
| 1172 | { |
| 1173 | if ( isMethod( "onSelect" ) ) |
| 1174 | Con::executef( this, "onSelect", Con::getIntArg( mEntries[ mSelIndex ].id ), mEntries[mSelIndex].buf ); |
| 1175 | |
| 1176 | // Execute the popup console command: |
| 1177 | execConsoleCallback(); |
| 1178 | } |
| 1179 | else if ( isMethod( "onCancel" ) ) |
| 1180 | Con::executef( this, "onCancel" ); |
| 1181 | |
| 1182 | // Pop the background: |
| 1183 | GuiCanvas *root = getRoot(); |
| 1184 | if ( root ) |
| 1185 | root->popDialogControl(mBackground); |
| 1186 | |
| 1187 | // Kill the popup: |
| 1188 | mBackground->removeObject( mSc ); |
| 1189 | mTl->deleteObject(); |
| 1190 | mSc->deleteObject(); |
| 1191 | mBackground->deleteObject(); |
| 1192 | |
| 1193 | mBackground = NULL; |
| 1194 | mTl = NULL; |
| 1195 | mSc = NULL; |
| 1196 | |
| 1197 | // Set this as the first responder: |
| 1198 | setFirstResponder(); |
| 1199 | } |
| 1200 | |
| 1201 | //------------------------------------------------------------------------------ |
| 1202 | bool GuiPopUpMenuCtrl::onKeyDown(const GuiEvent &event) |
no test coverage detected