[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-dev] Focus handling



Luke,

I'm trying to integrate the new popup slider code and am running across
a difficulty where once a new value is selected, it leaves the focus
within the "combo box".

I couldn't work out why this didn't affect "normal" combo boxes, then
eventually I found this in stdbars.cpp at line 250

if (IS_OUR_DIALOG_MSG(Msg))
{
	// Handle ok button
	if ((DMsg->DlgMsg == DIM_COMMIT) || (DMsg->DlgMsg == DIM_CANCEL))
	{
		Close(); // Hide the dialog
		m_pOpDesc = NULL; // zap out OpDescriptor pointer
		End();
		return OK;
	}
	// Else fall through
}
else
{
	if( DIM_SELECTION_CHANGED == DMsg->DlgMsg )
	{
		TRACEUSER( "luke", _T("Change focus") );
		AfxGetApp().GiveActiveCanvasFocus();
	}
}

The bottom bit is what restores the focus to the canvas having
made a selection from the combo box (because wxWidgets wants
to leave the focus in the combo box).

However, this seems to work mostly by accident. In fact all the
focus restores are done by the status line! This is because
the code above is only called when IS_OUR_DIALOG_MSG() is
/FALSE/ (i.e. if it's someone else's dialog message).

I /think/ what should be happening here is that it should be
doing the call below (and restoring focus) inside the first
if(), i.e. if IS_OUR_DIALOG_MSG() returns true. This of course
depends on bar handlers remembering to pass events to the
base class, even when the have been used. Not everything
does this. In fact the status line seems to be the main thing
that does.

Can I suggest a much simpler solution, which is that whenever
DialogManager generates these events for control on any sort
of bar, after processing them it gives focus back to the
canvas? I presume the specific problem with the popup slider
is that changing the slider does not generate a
DIM_SELECTION_CHANGED (instead it generates whatever the
slider event is). So I can fix this up for now looking at
DIM_SLIDER_SET or whatever, but it is bizarre having the
status line doing our focus handling...

Alex