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 7833781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:53:42+00:00 2026-06-02T12:53:42+00:00

We know how to program Matlab to do something when a button is clicked,

  • 0

We know how to program Matlab to do something when a button is clicked, which is this:

    button= uicontrol('Style','pushbutton','String','click me',...
   'Position',[260 80 60 20],...
   'Callback','disp ('' The button is clicked'')');

So the piece of code or function placed after ‘callback’ will be called whenever that button is pressed and released.( so the handler will be called only upon release of the button)

However I wanna be able to activate some code whenever the button is held down and not yet released. How can I do that?

  • 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-02T12:53:43+00:00Added an answer on June 2, 2026 at 12:53 pm

    You must use a callback function for the “ButtonDownFcn” property. From here:”

    ButtonDownFcn

    string or function handle (GUIDE sets this property)

    Button-press callback routine. A callback routine that can execute
    when you press a mouse button while the pointer is on or near a
    uicontrol. Specifically:

    If the uicontrol’s Enable property is set to on, the ButtonDownFcn
    callback executes when you click the right or left mouse button in a
    5-pixel border around the uicontrol or when you click the right mouse
    button on the control itself.

    If the uicontrol’s Enable property is set to inactive or off, the
    ButtonDownFcn executes when you click the right or left mouse button
    in the 5-pixel border or on the control itself.

    This is useful for implementing actions to interactively modify
    control object properties, such as size and position, when they are
    clicked on (using selectmoveresize, for example).

    Define this routine as a string that is a valid MATLAB expression or
    the name of a code file. The expression executes in the MATLAB
    workspace.

    To add a ButtonDownFcn callback in GUIDE, select View Callbacks from
    the Layout Editor View menu, then select ButtonDownFcn. GUIDE sets
    this property to the appropriate string and adds the callback to the
    code file the next time you save the GUI. Alternatively, you can set
    this property to the string %automatic. The next time you save the
    GUI, GUIDE sets this property to the appropriate string and adds the
    callback to the code file.

    Use the Callback property to specify the callback routine that
    executes when you activate the enabled uicontrol (e.g., click a push
    button).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# program which should call Matlab for running a m-file and
I'm trying to write a program that cleans data, using Matlab. This program takes
Just curious does anyone know a program or script to generate a style sheet(with
I am working on converting a MATLAB program to C and I don't know
I'd like to know whether it was possible to do this with Matlab or
As we all know Java program will start executing from the public static void
I want my program always know all of the mountpoints. After a quick google
How to run a program and know its PID in Linux? If I have
My program needs to know when a user ejects cd disc. Is there some
I know that being open source does not necessarily makes a program more/less secure

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.