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

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.

Related

How do I loop something and wait for something before re-looping? [swift]

Im basically trying to make a segment of code run over and over once they tap once, and run only if the previous run was completed.
How would I do this exactly, Im completely new to Swift.
At the end of your first loop, put a variable that sets to true and then under the IBAction where they tap once, check if that variable is true or not and if it is true, do your re-loop.
Another way you could do it is loop in the viewDidLoad, which is called before any visuals appear. This way, there's no way they could tap the button or whatever you're monitoring until the view has appeared, which is a separate function.
But I doubt you need to wait for a loop to finish, because the execution time of a loop is so fast it will have happened before they can tap (unless it's a very long loop).
1) IBAction ( code would start to run)
2) You could use a if statement to check to see if what you want done is done.
3) You could use a for to determine how long the code is ran.

GWT setSkipRowHoverCheck on abstract cell table

I have set the flag skipRowHoverCheck to true on the AbstractCellTable through the setter. By setting a debug point on the method onBrowseEvent2 inside AbstractCellTable I can confirm that the flag is set to true.
The code never executes the block where the skipRowHoverCheck is checked for being true, so no MouseOver browse events are added.
However, on debugging the project, the mouse over events are still caught and the row level hover events are picked up. This then makes the rows the mouse hovers over the selected row which is what we do not want.
Any advice on this would be great!
Thanks
The skipRowHoverCheck flag is used to avoid DOM restyling of the hovered row and firing of RowHoverEvents (handled by using addRowHoverHandler(RowHoverEvent.Handler handler)).
It is not used to avoid sinking the low-level BrowserEvents.MOUSEOVER and BrowserEvents.MOUSEOUT events. They are still fired, handled (with a no-op, if you have used setSkipRowHoverCheck(true)) and, if necessary, delegated to the underlying cell.
I don't know if I correctly understood your question, but this is the way the skipRowHoverCheck flag was meant to be.

Avoid interruption of callback functions in Matlab GUI

I have a Matlab GUI that needs a high time to execute some callback functions. Besides, these functions include the following code:
drawnow('expose');
pause(handles.data.delay);
I want to avoid that those callback executions get interrupted in order to avoid data inconsistency if the user presses other buttons. Thus, I modify the figure settings as:
set(handles.figure, 'BusyAction','cancel', 'Interruptible','off');
However, the callbacks are still interrupted. How can I avoid it?
Note: I think that the problem is that I need to propagate the 'BusyAction' and 'Interruptible' values to all the controls in my GUI, is there any way to do it automatically? Like, for example, modifying the default value before generating the GUI.
The fastest and cleanest way to propagate any property to all UI objects is with findobj:
set(findobj('Type','uicontrol'), 'BusyAction','cancel', 'Interruptible','off');

gtk.fixed layout laid out events?

I have a gtk.Fixed. I move components inside it around using:
myFixed.move( myEventBox, new_x, new_y )
What event do I listen for to know when myEventBox has been rendered at its new position?
Do I connect to the fixed or the eventbox?
MORE INFO:
I need this information so I know when it is safe to queue a video under the eventbox... if I do it too soon (e.g. right after calling myFixed.move) I can see the glitch. Currently getting around this with a gobject.idle_add.
To be honest, I am not aware of any such event. The object should move immediately and redraw the screen, but I don't think any signal is emitted when that happens.
The PyGTK documentation is very comprehensive, and it will list all of the functions and events of every object in the library. In searching (through both the gtk.Container (for fixed) and gtk.Widget (for fixed and eventbox) signal lists, I can't find any such event. The closest thing is an "add" signal in gtk.Container, but I don't think that's what you're looking for.
If the object is not moving, please post your code, because there is probably a subtle error.
If the object is moving just fine and you just want the event/signal, you may have to simulate it yourself. Write the function you want to be called as soon as the object is moved in a function (def) inside "__ init __", and then call that function in code in the line right after "myFixed.move".

MATLAB: Perform callback on variable change?

I am trying to build a GUI with several tabs, using uitabpanel() found at http://www.mathworks.com/matlabcentral/fileexchange/11546 . I would like to resize the GUI based on the currently opened tab; this is available with uitabpanel.SelectedItem.
Basically I would like to build a callback in order to monitor uitabpanel.SelectedItem - when this variable changes, the GUI window should resize appropriately. Generally speaking, I am looking for a way to monitor a variable and execute a callback when the variable changes value.
Is this possible? How would I go about doing this?
Thanks!
I don't have a MATLAB in front of me right now, but if it is implemented as a property -- and as far as I can tell from a quick look at the code, it is -- you can use addlistener function and provide a callback function for it.
addlistener(hTab,'SelectedItem','PostSet',#(s,e)disp('SelectedItem changed'))
I'm not familiar with uitab from the file exchange. However, if it's build upon the built-in uitab, then there should be a selectionChangeCallback or selectionChangeFcn property (depending on your Matlab version). Specify a function for this callback property, and you have a way to execute a function whenever the selection changes.
If that's not possible, the only other way to monitor a variable change (if you can't somehow use objects and set methods) is to use a TIMER OBJECT that periodically polls the value of the variable.
EDIT Since the FEX uitab is based on uipanel, the callback you're looking for is most likely ButtonDownFcn. Before you change it, make sure that it's not used by the uitab function, otherwise, you will want to edit that function.