call display() instead of glutPostRedisplay() in reshape? - glut

In reshape() function, can I simply call the callback function display() instead of glutPostRedisplay()?

You could, but it wouldn't be a good idea. Just let the message handler do its job.
If you need more control over message handling and rendering, you should use GLFW.

Related

How do I hookup for each setter

I am programming vb.net. I would like to register everytime a property has been "set". But rather than create a Sub and call it from every property setter, I'd like it to be triggered automatically any time the setter is called. Is there any kind of "hookup" system I can use to achieve this?
There is an existing thread that explains how you can achieve this using the INotifyPropertyChanged Interface:
Implementing INotifyPropertyChangedEvent

Display info message on INITIALIZATION

I want the user to notice that the report he's currently using is deprecated and replaced by another one. Therefore I'll need to have a popup like an info message on program start.
But when I try to run my code like this:
INITIALIZATION.
MESSAGE i355(zz).
The message only appears in the status bar.
This approach would look okay from user side:
INITIALIZATION.
DATA: w_mes TYPE string.
MESSAGE i355(zz) INTO w_mes.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
textline1 = w_mes.
But in fact it's very messy.
Is there a smoother way to display an info message on program start?
According to the behavior matrix of the MESSAGE statement in Dialog Processing, that is not possible. You might want to move the statement to a different section, e. g. START-OF-SELECTION.
You could use DISPLAY LIKE for a message that is originally of type E to achieve what you want but then the users will not be able to execute this deprecated version at all.
INITIALIZATION.
MESSAGE e184(sabapdocu) WITH 'Sorry, Batory!' DISPLAY LIKE 'I'.
Such a message will be displayed as a popup.
One can imagine that this is not allowed to preserve both the ability to call report programs using SUBMIT from all contexts(i.e. batch, rfc, update) and to allow external subroutine calls(PERFORM ABC IN PROGRAM XYZ).
In instances where this sort of thing is required, perhaps it is best to configure a transaction code(using SE93) to call the program in some way such that the message is displayed.
Here's a quick example using a local class:
CLASS lcl_selcr_mess DEFINITION.
PUBLIC SECTION.
METHODS
start. "#EC CALLED
ENDCLASS.
CLASS lcl_selcr_mess IMPLEMENTATION.
METHOD start.
MESSAGE i001(00) WITH 'Deprecated...' DISPLAY LIKE 'I'.
CALL SELECTION-SCREEN 1000.
ENDMETHOD.
ENDCLASS.
If you feel this approach is obtrusive, I suspect this can also be done by creating a "dummy" screen which only displays the message, then passes flow to the selection screen. Create a dialog transaction to call the dummy screen.

Can I call a method without triggering its event listeners?

Is there any sort of flag or way to call a method without triggering any event handlers?
FOR EXAMPLE
I'm handling a controlTextDidChange method and checking to see if the character returned by a keystroke is valid. If it's not, I remove it; if it is, I append a word. The problem is that when I change the text while in controlTextDidChange, controlTextDidChange is called again and the program will loop indefinitely. I know I can use an instance variable to get around this, but is there any sort of flag or way to call a method without triggering any event handlers?
To expand the comment into a quick answer.
You have a method that issues a notification by design. You want it to not issue that notification. You don't have an alternative available that does the same thing w/o the notification. If you want it to never issue that notification, and you have access to the code for the method, you could swizzle the method to a version where you've just commented out the notification. Of course, if you had the code, you could just add another method, and call that one. So you don't have the code, and all that's moot.
Can't you just bracket that invocation in code that removes the listener and then restores the listener? In other words, psuedocode like this:
[self.controlThingy removeObserver:self]
[self.controlThingy myMethod]
[self.controlThingy addObserver:self]
You've then made self deaf to notifications for that one invocation of myMethod. I've done similar things with bindings and KVO.

how to continue after calling objc_msgSend

I am doing meta-programming with objective-C and try to automate some of an application functions. Thus, I am not changing the source code files and the view controllers of the application but from another file I am managing to get the UI navigation stack and I am using Objective-C Runtime Reference to find the tappable UI elements and the actions. for example for a button I found the target and action and call objc_msgSend to programatically fire the event.
step = (NSObject *)objc_msgSend(element.target, NSSelectorFromString(element.action));
However I need to be notified when the action was done, or in other word, I need to wait until the action was done and then continue my automation. I was thinking of using NSNotificationCenter
//To raise an event
[[NSNotificationCenter defaultCenter] postNotificationName:FIRE_EVENT_NOTIFICATION object:self];
but doesn't look like working.
I am even thinking of using Categories or
So I am not sure if there is anyway to wait for objc_msgSend and where should I continue.
It isn't entirely clear what you are trying to do and the exact problem that you are having but I'll have a go at answering your question.
If I understand correctly you are trying to fire the action associated with a UI element, presumably something like a button press. You have a reference to the element in element and you want to call the associated action on the elements target. The following assumes the action is an IBAction.
The simplest way to do this would presumably be:
[element.target performSelector:element.action];
Note: element.action almost certainly returns a SEL (a selector) not an NSString so there is no need to run it through NSSelectorFromString().
Normally, an IBAction event would receive the clicked on element as a parameter so I think you might want to do:
[element.target performSelector:element.action withObject:element];
IBAction's have no return value so there is nothing to store when the method returns.
performSelector: and performSelector:withObject: will only return once the called method has run to completion. You shouldn't need to organise some sort of notification of the action completing.
However, if the action you are calling is launching code on another thread then it is possible that the called action will return before the result of pressing the button has completed. This will be difficult to monitor without knowledge of the code that is being run.
If, for some reason, you have to use objc_msgSend then you would use the following:
objc_msgSend(element.target, element.action, element);
Like performSelector:, objc_msgSend will only return when the called method has run to completion.
Hopefully I have understood your question and my answer makes sense, it is entirely possible I'm barking up the wrong tree though.

How can I use the FilterFunction passed to Gdk.Window.AddFilter?

I need to intercept several events before they are delivered to the widget's standard handlers, so I've done this already:
//Inside the definition of my custom widget
protected override void OnRealized()
{
base.OnRealized();
this.GdkWindow.AddFilter(PreFilterMessage);
...
}
So, later I define the PreFilterMessage method:
public Gdk.FilterReturn PreFilterMessage(IntPtr xEvent, Gdk.Event evnt)
{
Console.WriteLine(evnt.Type);
...
}
But the thing is that when I test it, whatever message gets to the window (KeyEvent, ButtonEvent, etc.) it always prints "Nothing", so I'm only getting empty events every time. Somewhere I read that the real information gets through the xEvent parameter, but that's just an IntPtr, so I don't know how to get the information I need (event type, pointer coordinates, etc.) from it.
Can anyone tell me how to do this? Thanks in advance.
Per the docs on the gtk.org website, the GdkEvent received in the filter func is unpopulated. The purpose of this AddFilter mechanism is to allow the user to intercept X events before the gdk event processing starts up. We do not bind any of the X data structures in Gtk#, so you would need to manually marshal that data from the IntPtr using System.Runtime.InteropServices Marshal.
So, unless that sounds familiar as far as what you are trying to accomplish, you may want to consider other alternatives.