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

  • Home
  • SEARCH
  • 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 6538895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:47:28+00:00 2026-05-25T10:47:28+00:00

I use the following pattern in Manipulate Dynamic[Refresh[….logic to handle v changes…., TrackedSymbols->{v}]] in

  • 0

I use the following pattern in Manipulate

Dynamic[Refresh[....logic to handle v changes...., TrackedSymbols->{v}]]

in setting up the logic.

I use the above to represent an ‘event handler’, where ‘v’ is the control variable that the user changes. So, When a specific control variable changes, there is specific code to take care of the logic needed to handle this one variable being changed. This simulates ‘callback’ in other GUI programming systems.

This works very well. Except at initialization time, since Manipulate will ‘fire’ these refreshes when Manipulate first come up on the screen, even without me changing the slides.

Also, the order in which it decides to ‘fire’ the refresh can not be depended on. This makes it hard to initialize the state of the program.

Here is an example

Manipulate[

 Row[{
   Dynamic[Refresh[Print["x changed"]; {x, y, z}, TrackedSymbols -> {x}]],
   Dynamic[Refresh[Print["y changed"];  "", TrackedSymbols -> {y}]],
   Dynamic[Refresh[Print["z changed"];  "", TrackedSymbols -> {z}]]
   }
  ]
 ,
 {{x, 1, "x"}, 0, 10},
 {{y, 1, "y"}, 0, 10},
 {{z, 1, "z"}, 0, 10}
 ]

If you run the above, you’ll notice the 3 print messages come up, without touching the controls.

My question: is there a way to prevent this initial refresh? I want the refresh code to run when I actually change the variable using the slider.

You might say, what is the big deal, let it refresh initially and run the logic as if the variables did change by the user.

Yes, I do that now. but I am trying to make it more efficient by reducing unnecessary work. Since the code will run some long computation each time a control variable changes, and this makes the Manipulate take more time than needed when it first come up, since the computation in each control variable has to run once.

I can introduce an extra ‘state variable’ to control this, and check that all events has ‘fired’ once, by counting, before starting the real work. Once all events fire once, I can set this variable to True, and only run the real code when the event fires and this state variable is true as well.

But I thought to ask if there might be a build-in way or smarter way to handle this without introducing more complicated logic in the code as I could not find an option or a setting to handle this.

Thanks,

  • 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-05-25T10:47:29+00:00Added an answer on May 25, 2026 at 10:47 am

    So, this is not really general and not pretty and just a workaround, but it does what you want:

      Manipulate[Module[{refx, refy, refz}, 
       If[{x,y,z} == {1,1,1}, {x, y, z}, 
        Row[{Dynamic[Refresh[
            Print["x changed"]; 
             {x, y, z}, TrackedSymbols -> 
             {x}]], Dynamic[Refresh[
            Print["y changed"]; "", 
            TrackedSymbols -> {y}]], 
          Dynamic[Refresh[
            Print["z changed"]; "", 
            TrackedSymbols -> {z}]]}]]], 
      {{x, 1, "x"}, 0, 10}, 
      {{y, 1, "y"}, 0, 10}, 
      {{z, 1, "z"}, 0, 10}]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I frequently use the following pattern to set an upper bound to the running
How should I use the unit of work pattern in the following scenario: I'm
I am trying to use following pattern. #ifndef TRACER_H #include Tracer.h #endif This is
I use following sample URL pattern to search pattern on my web site. http://www.mysite.com/search/
I use the following listener to listen to a particular pattern. I expects to
I use the following pattern in my JS: var lib = { module_one: {
What configuration values are needed to setup Log4j to use the following pattern? MyApp-Mon.log
I'll often have objects with properties that use the following pattern: private decimal? _blah;
In my application I use the following pattern for calling the DB: //do a
Is following pattern ok/safe ? Or are there any shortcomings ? (I also use

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.