On Tue, 21 May 2013 14:25:35 -0700 Carl Godkin wrote:
CG> Is it possible to determine the currently selected file in a native file
CG> dialog (before the user presses "OK," that is) ?
Not currently. However I believe others had requested this in the past
(although I can't find any ticket for it right now) and the good news is
that it should be possible and even relatively simple to implement for both
MSW and GTK (as usual, I have no idea about OS X).
Under MSW we just need to add another case to the existing
wxFileDialogHookFunction and generate an event when we get CDN_SELCHANGE.
Under GTK we need to connection to "selection-changed" signal in
wxFileDialog. And, of course, it would be pretty simple to implement this
in the generic version too.
On Tue, 21 May 2013 14:25:35 -0700 Carl Godkin wrote:
CG> Is it possible to determine the currently selected file in a native file
CG> dialog (before the user presses "OK," that is) ?
Not currently. However I believe others had requested this in the past
(although I can't find any ticket for it right now) and the good news is
that it should be possible and even relatively simple to implement for both
MSW and GTK (as usual, I have no idea about OS X).
Under MSW we just need to add another case to the existing
wxFileDialogHookFunction and generate an event when we get CDN_SELCHANGE.
Under GTK we need to connection to "selection-changed" signal in
wxFileDialog. And, of course, it would be pretty simple to implement this
in the generic version too.
So if you need this functionality, please consider adding it to wxWidgets.
It shouldn't be very difficult and would definitely be useful.
CG> However, I'm not sure what the best way to pass the name of the currently
CG> selected file to the extra controls would be. What I've done for now in my
CG> implementation is simply to use the extra control's client data hook:
CG> m_extraControl->SetClientObject (new wxStringClientData (filename));
CG>
CG> before calling UpdateWindowUI.
CG>
CG> Is there a better way you'd recommend?
It's not totally clear to me what are we trying to do here. I thought we
started from the idea that an event should be generated when the selection
in the dialog changes. With this approach, the code handling this event
would also update any custom controls in the dialog and it would already
have the name of the selected file.
However you seem to have switched to a completely different approach since
then, and now the controls are supposed to update themselves from their
idle or update UI event handlers. In this case, the best would seem to be
to provide wxFileDialog::GetCurrentlySelectedFileName() or something
similar so that they could retrieve the selected item from the dialog
itself.
On Tue, 28 May 2013 11:42:55 -0700 Carl Godkin wrote:
CG> Yes, an event is generated when the current selection in the dialog
CG> changes. This event, however, is internal to the wxFileDialog code
CG> specific to each port.
I think the confusion is related to the use of the word "event". For me,
an event was a wxWidgets event, e.g. wxEVT_FILEDIALOG_SELECTION_CHANGED or
something like this.