3

MATLAB GUI に「TYPE SEARCH HERE」という「編集」ボックスが必要です。ユーザーがボックス内をクリックすると、「TYPE SEARCH HERE」が消えて、入力を開始するための空の編集ボックスが表示されます...

何か案は?

4

4 に答える 4

4

少なくとも私のシステムでは、次のコードを使用してユーザー入力ボックス/ウィンドウを設定すると

prompt    = 'Enter search terms:';
dlg_title = 'My input box';
num_lines = 1;
defAns    = {'TYPE_SERACH_HERE'};

answer = inputdlg(prompt, dlg_title, num_lines, defAns);

デフォルトのテキストTYPE_SEARCH_HEREが強調表示されているので、入力を開始するだけで、必要なものに置き換えることができます。

編集別の方法として、既存のuicontrol編集ボックスがある場合は、次のようにすることもできます。

function hedit = drawbox()

  hedit = uicontrol('Style', 'edit',...
      'String', 'deafult',...
      'Enable', 'inactive',...
      'Callback', @print_string,...
      'ButtonDownFcn', @clear);

end

function clear(hObj, event) %#ok<INUSD>

  set(hObj, 'String', '', 'Enable', 'on');
  uicontrol(hObj); % This activates the edit box and 
                   % places the cursor in the box,
                   % ready for user input.

end

function print_string(hObj, event) %#ok<INUSD>

  get(hObj, 'String')

end
于 2012-01-05T15:11:35.110 に答える