Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7924787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:56:21+00:00 2026-06-03T17:56:21+00:00

When working with Matlab GUIs, is there a way to place a hint in

  • 0

When working with Matlab GUIs, is there a way to place a “hint” in an Edit Text box? That is, text that will disappear once the user starts typing? I’ve used similar functionalities in Android, but I’m not as familiar with other GUIs, so I’m not sure how widespread this functionality is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:56:24+00:00Added an answer on June 3, 2026 at 5:56 pm

    This is possible in Matlab, but you have to define a custom MouseClickCallback, which is only accessible using findjobj by Yair Altman (download it from the Matlab File Exchange using the link and save it somewhere on your Matlab path).

    Since I like the idea, I have written a function that conveniently takes care of all this. It creates a grayed-out, italic help text that disappears once you click the edit box.

    enter image description here

    function setInitialHelp(hEditbox,helpText)
    %SETINITIALHELP adds a help text to edit boxes that disappears when the box is clicked
    %
    % SYNOPSIS: setInitialHelp(hEditbox,helpText)
    %
    % INPUT hEditbox: handle to edit box. The parent figure cannot be docked, the edit box cannot be part of a panel.
    %       helpText: string that should initially appear as help. Optional. If empty, current string is considered the help.
    %
    % SEE ALSO uicontrol, findjobj
    %
    % EXAMPLE   
    %           fh = figure;
    %           % define uicontrol. Set foregroundColor, fontAngle, before 
    %           % calling setInitialHelp
    %           hEditbox = uicontrol('style','edit','parent',fh,...
    %             'units','normalized','position',[0.3 0.45 0.4 0.15],...
    %             'foregroundColor','r');
    %           setInitialHelp(hEditbox,'click here to edit')
    %
    
    % check input
    if nargin < 1 || ~ishandle(hEditbox) || ~strcmp(get(hEditbox,'style'),'edit')
        error('please supply a valid edit box handle to setInitialHelp')
    end
    
    if nargin < 2 || isempty(helpText)
        helpText = get(hEditbox,'string');
    end
    
    % try to get java handle
    jEditbox = findjobj(hEditbox,'nomenu');
    if isempty(jEditbox)
        error('unable to find java handle. Figure may be docked or edit box may part of panel')
    end
    
    % get current settings for everything we'll change
    color = get(hEditbox,'foregroundColor');
    fontAngle = get(hEditbox,'fontangle');
    
    % define new settings (can be made optional input in the future)
    newColor = [0.5 0.5 0.5];
    newAngle = 'italic';
    
    % set the help text in the new style
    set(hEditbox,'string',helpText,'foregroundColor',newColor,'fontAngle',newAngle)
    
    % add the mouse-click callback
    set(jEditbox,'MouseClickedCallback',@(u,v)clearBox());
    
    % define the callback "clearBox" as nested function for convenience
        function clearBox
            %CLEARBOX clears the current edit box if it contains help text
    
            currentText = get(hEditbox,'string');
            currentColor = get(hEditbox,'foregroundColor');
    
            if strcmp(currentText,helpText) && all(currentColor == newColor)
                % delete text, reset color/angle
                set(hEditbox,'string','','foregroundColor',color,'fontAngle',fontAngle)
            else
                % this is not help text anymore - don't do anything
            end
    
        end % nested function
    
    end % main fcn
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with Matlab code that writes coordinates to a text file as
I am working with a matlab project. And I have a text file like
I'm working on a function in MATLAB that reads input from a file. So
I'm currently working on a my own neuroimaging toolbox that runs under MATLAB /
I'm working with a Matlab API that loads data from a proprietary format into
I'm working with a matlab code package that was handed down to me. It
I'm working on a Matlab GUI application that has multiple views. It behaves sort
I have some MATLAB code I've been working with. There are three sections, say
I have some experience in working with java, but many are telling MATLAB will
I am working with some matlab code that processes data (in a Kalman Filter)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.