Here's an image of my input config dialog to give the idea:
The idea is the user clicks on the button they want to change, then I pop up a new modal dialog which waits and listens for keyboard/joystick input, and exits once it detects a key press. Additionally, there's that "Set All Buttons" button which steps through each button and opens that listening dialog repeatedly for each button.
This is all working... however there's an ugly delay that happens and I can't figure out why. It's especially noticable when you press the Set All Buttons button -- once the first dialog closes, nothing happens (the next dialog doesn't open) until you either move the mouse... press a key... or do something else that sends a message to the dialog.
It's very inconvienient, since the user will have their hands on their controller or keyboard at this point in the program... and pressing keys to get past the delay will interfere with the input for the next button -- and having to move your hand over to the mouse between each button is annoying and eliminates the conveinience of using the Set All Buttons button.
Between the first dialog closing and the next opening, the only thing I'm doing is changing the label of the buttons to reflect the key the user just assigned to that button. I'm not doing anything that should cause this kind of hangup. Here is relevent code (truncated to avoid my post from being huge):
Code: Select all
// called on "Set All Buttons" press
void dlg_configinput::OnCont_SetAll(wxCommandEvent& event)
{
int sel = mControllerSelection->GetSelection();
if((sel < 0) || (sel > 3)) return;
sel = (sel * (BTN_P2_A - BTN_P1_A)) + BTN_P1_A;
if(dlg_inputlistner::Go(this,&pBtns[sel+4],wxT("Button for: Up"))) LoadControllerNames();
if(dlg_inputlistner::Go(this,&pBtns[sel+5],wxT("Button for: Down"))) LoadControllerNames();
if(dlg_inputlistner::Go(this,&pBtns[sel+6],wxT("Button for: Left"))) LoadControllerNames();
if(dlg_inputlistner::Go(this,&pBtns[sel+7],wxT("Button for: Right"))) LoadControllerNames();
if(dlg_inputlistner::Go(this,&pBtns[sel+2],wxT("Button for: Select"))) LoadControllerNames();
if(dlg_inputlistner::Go(this,&pBtns[sel+3],wxT("Button for: Start"))) LoadControllerNames();
if(dlg_inputlistner::Go(this,&pBtns[sel+1],wxT("Button for: B"))) LoadControllerNames();
if(dlg_inputlistner::Go(this,&pBtns[sel+0],wxT("Button for: A"))) LoadControllerNames();
if(dlg_inputlistner::Go(this,&pBtns[sel+9],wxT("Button for: Turbo B"))) LoadControllerNames();
if(dlg_inputlistner::Go(this,&pBtns[sel+8],wxT("Button for: Turbo A"))) LoadControllerNames();
}
// called to refresh the labels of the controller buttons
void dlg_configinput::LoadControllerNames()
{
int oft = mControllerSelection->GetSelection();
if((oft < 0) || (oft > 3))
return;
else
{
oft *= (BTN_P2_A - BTN_P1_A);
oft += BTN_P1_A;
mCont_A->SetLabel( InputManager::GetButtonName(pBtns[oft+0]) );
mCont_B->SetLabel( InputManager::GetButtonName(pBtns[oft+1]) );
mCont_Select->SetLabel( InputManager::GetButtonName(pBtns[oft+2]) );
mCont_Start->SetLabel( InputManager::GetButtonName(pBtns[oft+3]) );
mCont_Up->SetLabel( InputManager::GetButtonName(pBtns[oft+4]) );
mCont_Down->SetLabel( InputManager::GetButtonName(pBtns[oft+5]) );
mCont_Left->SetLabel( InputManager::GetButtonName(pBtns[oft+6]) );
mCont_Right->SetLabel( InputManager::GetButtonName(pBtns[oft+7]) );
mCont_TurboA->SetLabel( InputManager::GetButtonName(pBtns[oft+8]) );
mCont_TurboB->SetLabel( InputManager::GetButtonName(pBtns[oft+9]) );
}
}
// called to open up the new dialog that waits and listens for keypresses
// returns nonzero if the user selected a new button
int dlg_inputlistner::Go(wxWindow* parent,BUTTON* btn,const wxString& message)
{
dlg_inputlistner* dlg = new dlg_inputlistner(parent,message);
dlg->pBtn = btn;
int ret = dlg->ShowModal();
delete dlg;
return (ret == wxID_OK);
}
I suspect the delay is happening after ShowModal exits, but before I change the labels. The reason why is because the labels changes don't become visible on screen until after I move the mouse.
Does anyone have any ideas what could be happening? How can I get around this? I'm using wxWidgets 2.8.7 on MSVS 2002 (yeah yeah, I know) and I'm running Windows 2000 SP4
Thanks in advance!