Comments on: OSX Window Activation Problem (SelectWindow)
REBOL Technologies

Comments on: OSX Window Activation Problem (SelectWindow)

Carl Sassenrath, CTO
REBOL Technologies
22-Apr-2005 17:55 GMT

Article #0157
Main page || Index || Prior Article [0156] || Next Article [0158] || 2 Comments || Send feedback

The REBOL OSX port has been moving along... and we were hopeful to get some of you early testers a prototype by this weekend. However, we've run into a problem. Perhaps some of you OS X experts might know the solution. Here is a discussion of the problem:

Short description:
The REBOL windows never get the "focus".

Long description:
OS X uses the SelectWindow() function to make a window active, bringing it to the front (top window) and allowing it to become the focus of keyboard and other events. However, for some reason, we cannot get this to happen. We do see mouse events without a problem, but the window never moves to the front, nor does it ever receive keyboard events. We have searched far and wide in the OSX developer documentation, but have yet to find a solution. A general search of the web does not provide an answer either.

A short example:
Here is a small C file that shows the problem: osx-window-problem See comments at the top.

A few details:

  1. The program Carbon based.
  2. The program is run from the Terminal shell (which may factor in, we don't know).
  3. The program is not an OSX "app". It is only a GCC built executable program.
  4. Adding a SetUserFocusWindow() does not fix the problem.
  5. The program contains no menus or other Carbon GUI elements (which should not matter, but again we don't know that for sure).
Solution Update:

Please read the solution we ended up using (at least for now). It does not totally meet our requirements, but at least it gets us most of what we need.

2 Comments

Comments:

Andrew Butcher
9-Nov-2006 19:37:54
Try calling osx_AllowForeground() (which follows) before you start doing windowing calls. The problem occurs because your application is not part of a bundle.

void osx_AllowForeground()
{
   ProcessSerialNumber psn; /* = { 0, kCurrentProcess }; */
   GetCurrentProcess(&psn);
   TransformProcessType(&psn, kProcessTransformToForegroundApplication);
   SetFrontProcess(&psn);
}
buddyontobuddy
4-Jul-2012 22:03:03
I have been researching every aspect of a possible career move. This post is very helpful and shows that you have a lot of knowledge on the topic. Do you have any others? do you agree

Post a Comment:

You can post a comment here. Keep it on-topic.

Name:

Blog id:

CS-0157


Comment:


 Note: HTML tags allowed for: b i u li ol ul font p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

Updated 31-May-2023   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code