Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Child Window Focus Question: (9 Items)
   
Child Window Focus Question  
I have a frame (created with PhWindowOpen) that has a child window that is borderless. When I create the child window, 
the frame (parent window) loses focus and the title bar turns grey. Is there a way to still mark the parent as active 
while having the child window have focus (like java awt) so that the frame doesn't turn grey?

Thx,
Bill
Re: Child Window Focus Question  
There is no way to do with just the windows. Since your child window doesn't have border, don't create a window region, 
create just a region instead. You will need to handle focus in this case yourself.
Re: Child Window Focus Question  
That was originally how I was planning on doing window popups. However I backed off because I couldn't figure out a way 
to handle the scenario where the popup window is partially outside the parent frame. From what I understand, the region 
will only receive events for where it intersects with the parent. So event like mouse move, boundry, etc would not be 
raised in the part outside the parent. Is there some way of handling these?
Re: Child Window Focus Question  
You "logical" parent window must not be the parent of your pop-up region. You need to make your "child" region to be an 
actual child of the root region for example. This way your "logical" parent becomes a sibling of your "logical child" 
and the child won't be clipped by the "logical parent".
Re: Child Window Focus Question  
 Misha, first, thanks for all the help you have been providing me. I definitely appreciate it. 

Second, I'm still having some issues here with this approach. Attached is a screenshot of my app showing a dropdown. The
 dropdown is a region owned by ROOT_RID. At the bottom it extends beyond my application window and covers up part of the
 terminal. Even though it is in front of the terminal window, anything that scrolls in the terminal, corrupts the 
content of the region. When I mouse over that part of the region it clears up because I do a repaint of the rows 
triggered off the mouse move. However I don't know what kind of events will help me when there is no mouse or keyboard 
input. Is there something I need to do differently as far as stacking order to help this? I noticed with various photon 
apps that have dropdowns (using widgets I assume) they don't exhibit this behavior. 

Here is the code I am using for creating the region:

JNIEXPORT jlong JNICALL Java_com_tridium_pwt_PwtApi_regionOpen0
  (JNIEnv *env, jobject jobj, jlong prId, jdouble x, jdouble y, jdouble width, jdouble height)
{
  PhRid_t rId;
  PhArea_t area;
  PhRect_t rect;
  PhRegion_t region;
  jlong jrId;

  memset(®ion, 0, sizeof(region));

  region.events_sense = Ph_EV_PTR_ALL | Ph_EV_KEY | Ph_EV_EXPOSE | Ph_EV_DRAG; 
  region.events_opaque = Ph_EV_PTR_ALL | Ph_EV_DRAW | Ph_EV_EXPOSE | Ph_EV_KEY;
  region.origin.x = (int)x;
  region.origin.y = (int)y;
  region.parent = prId;

  area.pos.x = 0;
  area.pos.y = 0;
  area.size.w = (int)width;
  area.size.h = (int)height;
  
  PhAreaToRect(&area, &rect);

  rId = PhRegionOpen(Ph_REGION_PARENT |
                      Ph_REGION_ORIGIN |
                      Ph_REGION_EV_OPAQUE |
                      Ph_REGION_EV_SENSE |
                      Ph_REGION_RECT | Ph_REGION_DATA,
                      ®ion, &rect, NULL);
                       
  if (rId <= 0)
  {
    throwPwtException(env, "Unable to open region");
    return -1; 
  }
    
  jrId = rId;

  PgSetRegion(rId);

  return jrId;
}


Thx,
Bill
Attachment: Image region_issue.png 50.47 KB
Re: Child Window Focus Question  
Your region needs to be opaque to blits: Ph_EV_BLIT.
Re: Child Window Focus Question  
Thx Misha. I wasn't familiar with that flag. That fixed the issue. One thing I'm curious about. Since regions don't 
receive WM events (in particular focus event) how do they know if they should receive mouse and keyboard event? It seems
 that Photon has to have some notion of focus for the regions so that they would get those events.
Re: Child Window Focus Question  
When PWM is running, it handles focus and it knows to whom to deliver key events. When there is no PWM, the Photon’s 
internal window manager will use the "pointer focus" method. The keys will be delivered to the region(s) under the 
pointer.
There is nothing special about mouse events in this regard. Regions that are sensitive to mouse events (there is a bunch
 of them) and not obstructed, will get these events.
Re: Child Window Focus Question  
Thanks Misha. I hadn't thought of that.