[Developers] Popping up an initial dialog
Bert Bril
Bert.Bril at opendtect.org
Tue Oct 27 12:00:58 CET 2009
Hi all,
Sometimes you want to launch a dialog, and from that immediately launch
another one. For example, a dialog which wants an input file, and you
want to immediately have the user select one. You'd have fields like:
inpfilefld_ = new uiFileInput( this, "Input foo file",
uiFileInput::Setup().withexamine(true) );
barfld_ = new uiGenInput( this, "Bar value", FloatInpSpec() );
barfld_->attach( alignedBelow, inpfilefld_ );
What you *could* do, is put this in the constructor:
uiFileDialog dlg( this, false, GetDataDir() );
dlg.go();
The effect is that the 'bar value' dialog does not show up until after
the user leaves the uiFileDialog. That can be pretty confusing.
... -> set a timer. That allows the underlying dialog to pop up, and the
user will see why the file dialog comes up. You can then also quit the
dialog altogether on a cancel:
Sketch:
uiFooBar( uiParent* p )
: uiDialog(p,Setup("Aap","Noot","") )
, timer_("FileDlg popup timer")
{
// fields created
timer_.tick.notify( mCB(this,uiFooBar,popupInitialFileDlg) );
timer_.start( 100, true ); // 100 msecs; user won't even notice
}
void uiFooBar::popupInitialFileDlg( CallBacker* )
{
uiFileDialog dlg( this, false, GetDataDir() );
if ( !dlg.go() )
done( 0 );
else
{
inpfilefld_->setFileName( dlg.fileName() );
handleNewFileName();
}
}
/Bert
--
-- Bert Bril / OpendTect developer at dGB
-- mailto:Bert.Bril at opendtect.org , http://opendtect.org
More information about the Developers
mailing list