GBinding update timing? - gtk3

I connected a property of my GtkApplication with a GtkEntry field in my Preference dialog through g_object_bind_property. Works like a charm.
However, it works a little too well, in that each and every character added/deleted/changed in the GtkEntry is reflected in the corresponding GtkApplication property. I would like this update to happen only the GtkField is activated by the user pressing . Is there any way to tweak the timing of the binding, or should I just handle the activate signal?

I don’t think there is a way to make GObject property bindings conditional on a signal or on the value of a property. I think you need to handle the activate signal manually, as you suspected.

Related

GUI: configure the racket:text% to read-only

I want to use an editor to display a log from a program, I just need a very basic text field:
With a vertical scrollbar
With a contextual menu for copy/paste
Prevent the user from changing the text
In order to activate the copy/paste menu, I use the class racket:text% from framework rather than the basic one.
How to prevent the user from changing the text?
I read the documentation, as far as I understand the closest thing I found is lock method:
https://docs.racket-lang.org/gui/editor___.html?q=lock#%28meth._%28%28%28lib._mred%2Fmain..rkt%29._editor~3c~25~3e%29._lock%29%29
But it is not convenient, as it also prevent my program to write the data.
I also find get-read-write? but cannot find set-read-write.
Use the lock method, and just unlock the editor around any modifications that you want to do. You may find it useful to write a call-with-unlock helper function or with-unlock macro.
If you do your updates from the eventspace's handler thread (and you probably should; use queue-callback if they originate from another thread), then as long as you re-lock the editor at the end of an update, the user will never be able to interact with the unlocked editor.

vscode extension onDidChangeCursorPosition

I am developing a vscode extention and I want provide something like the bracket match decoration. My problem is that I need to register onDidChangeCursorPosition and I don't know how to do that.
My purpose is to create a decorations that appears only when the cursor is on it.
There is no such event like onDidChangeCursorPosition. However you can use onDidChangeTextEditorSelection. The onDidChangeTextEditorSelection is actually a field on the vscode's window object and you can assign your own function to it which gets called when this event is sent. Look at my extension (or many others which do that) to learn how to handle the cursor change event.

How to call the default handler from within an event handler

I have a TStatusbar with 4 panels and one of them set in OwnerDraw style.
In the onDrawPanel() event handler, I would like the TStatusbar to use the default paint method before I add some custom drawing on top of it.
Is there a way I can call the default handler from my onDrawPanel handler?
EDIT
Well, I did found a fix, but I'm not sure how reliable it is if the system font change.
Since the default handler only draws the panel text, a simple call to TextRect will do the same trick.
StatusBar->Canvas->TextRect(Rect,Rect.Left,Rect.Top,Panel->Text);
But, I'm not sure how well this will work if the system font, language etc. isn't the default.
I would still like to get an answer to the original question.
TStatusBar is a wrapper for standard WinApi window class, so by default the painting is done by OS. You should look into WinApi functions, or messages like SB_SETTEXT
Check this on MSDN: SB_SETTEXT message
EDIT:
It seems DrawStatusText is the right WinApi function. SBT_NOBORDERS flag shall be specified if borders are not required.

Objective-C: Trigger method with computer keyboard stroke

Sorry if the questions is asked/answered already, or if my title is poorly worded.
I am currently writing an iPhone app, and have considered a useful tool for debugging. I would like to write a method that just prints variables and other info that I want. That part is simple and all, but I want this to be called by keystroke.
For now I have been just adding NSLog()'s to viewDidLoad or to other button methods to check if my variables are being set properly, but it's becoming tedious and the code is long so I tend to forget about some and spend a lot of time looking for them haha.
I just want one method that I can go to to write my NSLog()'s, and have that method call whenever I hit 'space' or something of that sort.
Can this be done?
Thanks!
-SF
It's pretty hard to do, you need to have a hidden text field that you keep in focus, hide the software keyboard for it, then listen on its delegate methods for changing text.
An alternative would trigger the code inside applicationWillResignActive: which gets called on application hiding, notification center showing, or double home press.

Xcode/iPhone -- break when the next event enters my code?

I am working on a large (>30k lines) event-driven app. I have a sequence of inputs that produces a bug. What I want to do is to break as soon as the final input enters my code.
Is there a general way to do that?
I understand that for any specific sequence of inputs, I can find out where that last input is going to enter my code, then set a breakpoint there. What I would like to do is take out the step of "find out where that last input enters my code." In other words, I am running the app in the simulator, and I want to set a flag somewhere that says "break the next time you are going to enter non-system Objective C code." Then I send the event that causes the problem.
I understand what you are asking, but have you tried using an Exception Breakpoint? This will basically act like an auto-inserted breakpoint on the piece of code that throws the exception. If that doesn't work for you, try a symbolic breakpoint
If you want to intercept UI events, you can try subclassing UIWindow and overriding its sendEvent: method, then setting this class as the class of the UIWindow object in your main XIB file. sendEvent: will be called each time the user generates a touch event. Unfortunately, at this point you cannot yet know which UI object will finally consume the event (read: which event handler code will be ultimately called) since that depends on the actual state of the responder chain. But anyway, you can use this method to inject events into the system.