Referencing DOM Elements in dash callback - callback

I would like to reference the value of an element in a dash callback. I don' want that element to be a trigger to my callback so I can't call it an input (otherwise it will trigger the input).
Is this possible or is the callback nature one in which the context is only in the inputs and outputs.
If this is not possible, is there a way to capture the callback trigger (yes ctx.triggered_id) and then return a no-op (i.e. don't do anything).
Worst case I have to rebuild 4 plots and a table for nothing if this field changes. It is essentially a category field. If the item (element of category) is empty when we trigger the callback (with another filter) I want to populate the item list with all items from the category - hence need to know current category.
If I change the category I have a different callback that sets the item selection values - that is all good.
I tried adding category as an input and returning nothing if that is the trigger (unsurprisingly this upsets things).
I could just let it run but it is spurious work for the system and not fast.

Just in case...anyone else is as "limited" as I.
dash.State is what I needed. It passes arguments without using them as triggers. So callback has Inputs, Outputs and States.

Related

Are there any ways to loop in a button press callback method until the button is released?

So im using gtkmm specifically here.
What I'm working on:
I'm implementing a feature in which when I press in a certain window a parameter is increased/decreased depending on if the mouse moves left/right.
What needs to be done:
To be able to somehow loop in the button press callback method -(doing so as each iteration would store the new value of the cursor position and compare it to the inital position to determine wheter increase value or decrease)- until the button is released.However the event which is sent remains the same so I cant just for example check to see if the events type becomes GTK_BUTTON_RELEASE. I have also tried to use a flag which is set to false in the button release call back, however the release callback isnt even called as the execution is stuck in the now infinite loop.
Thoughts
Im thinking maybe the solution could be a certain something to do with signals.
Update:
Gtk has two functions for doing what I was saying here exactly which are , gtk_events_pending(), and gtk_main_iteration(). Hever turns out having a limitless loop inside an event is considered a bad practise and its better to use other methods like here for example using GdkEventMotion, or other types.

Transitions in UML state charts: better to use triggers or guards?

In the design of UML state charts it appears that I can chose to use either triggers or guard logic to achieve transitions between states.
So which is better to use? Given the same logic for transition, does a trigger behave any differently than a guard? What are the benefits/drawbacks of one over the other?
Are there perhaps differences depending on the particular tool, or does the UML standard strictly define the behaviors of either method of transition?
I'm presently using Simulink Stateflow to design a state machine.
Those two are different concepts.
Trigger is an event occurrence which enables the transition,
while guard is a condition that must be evaluated to true in order for the transition to proceed.
So you cannot use them interchangeably — they have different roles.
Also note that the default guard (if none is specified) is [true], so the trigger is often sufficient to move from one state to another.
Update:
Summary:
Trigger (event) is some new data (of any data type) that was received by the object.
Guard is boolean expression on some data that is alrady present in the object.
Trigger (event) is an outside event that some other actor fired - user has pressed a button, browser requested a page load, etc. So in the image above, every time user presses a digit on a digital lock it fires "pressed digit" event.
If the pin (sequence of digits) is valid, then the transition to unlocked state will be enabled.
Yet another way to look at it:
If you press a keyboard key the system fires a keypress event, that would be a trigger whose value is the pressed key. Then you can make a guard [pressedKey = enter] (guard is always a boolean expression).
However having just the guard is not enough here, because there would be nothing to compare against.
Strictly speaking, guards cannot be used without triggers.
UML 2.5.1 specification (Section 14.2.4.8, page 331) defines State Machine's transitions by the following BNF expression:
[<trigger> [‘,’ <trigger>]* [‘[‘ <guard>’]’] [‘/’ <behavior-expression>]]
While UML 2.0 defined them as:
<transition> ::= <trigger> [‘,’ <trigger>]* [‘[‘ <guard-constraint>’]’] [‘/’ <activity-expression>]
Triggers are defined as:
<trigger> ::= <call-event> | <signal-event> | <any-receive-event> | <time-event> | <change-event>
So, in both cases, there cannot be a transition with a guard that doesn't have any trigger.
The only exception, according to UML 2.5.1, are internal transitions, which are specified by:
{<trigger>}* ['[' <guard>']'] [/<behavior-expression>]

What do these Array console.logs mean?

If I expand the Arrays, they all look the same on the inside. Why then is the first one labeled as [Array[4]] and the last one as [Array[4], Array[4], Array[4], Array[4]]?
Thanks!
As the little i icon explains, expand an object shows its present value.
This would happen if you log the same array instance multiple times, and add items between logs.
It prints the value of the array (the collapsed line) immediately, so it shows the original value of the array.
When you expand it, it expands the current state of the object, including later additions.

Synchronize two input fields , without building an endless loop?

I have two input fields which i would like to sync with each other.
Unfortunately, when I add a ChangeListener to each of the TextFields they will trigger each other,
and so create an andless loop.
Ofcourse I could unregister the Listeners, on every change and them put them back,
but is there any Java native approach?
Maybe something with bindings?
From general reasoning (i.e. not knowing swt or java): you can add a boolean flag (probably your class member) m_enteredChangeListener, temporary setting it to true in one of your handlers (not both), making the same handler do nothing if it's reentered recursively.

Can two panels share a uicontrol in a MATLAB GUI?

I've got a MATLAB GUI that has different aspects of functionality, each with their own panel of uicontrols. When one panel is selected, the other one is set to invisible, and vice-versa. However, they share some of the same inputs in the form of a popup menu. Can I include a 'clone' instance of the menu on the second panel somehow? I'd like to avoid as many redundant callbacks and uicontrols as possible.
I guess if the uicontrol was a direct child of the figure, you may be able to put it in front of everything.
A much simpler solution is to use the same callback for multiple uicontrols. In the property editor, you can modify the callback name and set it to a common callback function. Additionally, you can create a field (e.g. myPopupH) in the OpeningFcn of the GUI, in which you store the handles of the popups that should behave the same way. Then, in the callback, you'd use hObject, i.e. the first input argument, for all the get calls (to access the modified state of the popup-menu), but you'd use handles.myPopupH in all the set calls, so that you can ensure that both popups always have the same state. Thus, the ui-object may be redundant, but all the code (which is much more critical) only exists in a single copy.
One place where I routinely use a single callback for multiple ui elements is the close request function which is accessed from the "Cancel"-button as well as from the "X" that closes the figure, and possibly from one of the "File"-menu items.