5

If one creates an inputdialog with inputdlg and a default answer, it looks like that:

enter image description here

Which callback command do I need to make it look like that?

enter image description here

The documentation is missing a lot here. It's a kind of "luxury service" for the customer ;) But I think it would be nice, if it's easy to implement.


This question is actually solved, as I found out that there are convenient functions like uigetfile and uiputfile for my particular case. But the general case of my questions remains unsolved or at least I haven't tested the java approach.

Robert Seifert
  • 25,078
  • 11
  • 68
  • 113

1 Answers1

3

I'm afraid using the builtin inputdlg without changes this is not possible. At least there's not 'hidden' feature allowing for this.

You'd need access to the underlying java TextField object for that purpose. You could copy inputdlg to some new place and make your own version of it.

In combination with the findjobj utility the desired functionality in principle exists. http://www.mathworks.com/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects Things could look like this then:

% create the edit-field:
h = uicontrol('style', 'edit',...);
% get the underlying java object
% this should be a javahandle to a JTextField
jtextfield = findjobj(h);
% set start/end of the selection as desired:
jtextfield.setSelectionStart(startPos);
jtextfield.setSelectionEnd(endPos);
sebastian
  • 9,526
  • 26
  • 54
  • `inputdlg` does not seem to work "standalone" and I cannot find the missing function `getnicedialoglocation` (nice name btw.). However it seems quite fiddly just to get a little bit of more functionality. I think it's not worth it and I'll postpone it. Thank you anyway! – Robert Seifert Oct 16 '13 at 12:35
  • 1
    You could find that function in `/toolbox/matlab/uitools/private`. However you're probably right, its not really worth it if it's only a "nice-to-have"... – sebastian Oct 16 '13 at 12:41