• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Window with click-through areas
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window with click-through areas


  • Subject: Re: Window with click-through areas
  • From: Rolf <email@hidden>
  • Date: Wed, 12 Nov 2003 14:30:25 +0100

Hi Rick,

Thankyou for your suggestion. Using 4 windows sounds like a great idea, but since my app has multiple controls that must not be click-through a large number of windows would be needed. Anyways I will try it if the current method I'm experimenting with fails.

The method I'm experimenting with now only works partially (so far), and only on OS X 10.2 Basically what it does is to send the window setIgnoresMouseEvents:TRUE on left mouse button down, setIgnoresMouseEvents:FALSE on left mouse button up, and re-post all
mouse events using CGPostMouseEvent(); The idea is that the re-posted mouse events will be routed through the click-through area to the window that lies immediately "under" it.

Using this method I am able to double-click select text in text editing windows that lie "under" the click-through areas. However single clicking does not work. I am unable to pick up and move a window that lies "under" the click-through area, change the caret location in text
editing windows, etc. I think it has to do with the underlying windows not being "selected".

Anybody know how to fix this ?



Heres a simplified version of the code taken from the NSWindows's sendEvent:
(it is called when mouse is over areas that should be click-through)

// What type of mouse event occured ?
switch ([theEvent type]) {
case NSLeftMouseDown: {
// Enable click-through window
[self setIgnoresMouseEvents:TRUE];
// Initialize click-through
[self initializeClickThrough];
// We are now in click-through state until left mouse button is released
// Re-post left mouse-down event
CGPostMouseEvent(mouseLoc, FALSE, 1,TRUE);
break;
}
case NSLeftMouseUp: {
// Re-post left mouse-up event
CGPostMouseEvent(mouseLocCG, FALSE, 1,FALSE);
// Disable click-through windows (runs [self setIgnoresMouseEvents:FALSE] asynchronously)
[self performSelector: @selector(disableIgnoreMouseEvents) withObject:NULL afterDelay: 0.1];
}


... etc


The initializeClickThrough method does basically the following:

CGEnableEventStateCombining(TRUE);
// Don't let our events block local hardware events
CGSetLocalEventsFilterDuringSupressionState(kCGEventFilterMaskPermitAllEvents,kCGEventSupressionStateSupressionInterval);
CGSetLocalEventsFilterDuringSupressionState(kCGEventFilterMaskPermitAllEvents,kCGEventSupressionStateRemoteMouseDrag);


/Rolf

07.11.2003 16:32:09, skrev Rick Bourner <email@hidden>:

>Hi,
>
>I'm a newb (ish) to all of this but it sounds like you could do the
>following if all ease fails:
>
>Have 4 windows that are not click through surrounding one that is. The
>four contain the controls and are
>not click through and the one in the middle could be set to click
>through.
>
>Or perhaps you could track the location of the mouse and set
>setIgnoresMouseEvents:TRUE/FLASE as required, or
>do you loose the mouse location when TRUE?
>
>Well, I expect that there is an easier way, but if this helps I'm glad -
>
>Best,
>
>Rick.
>
>
>On Friday, November 7, 2003, at 02:43 pm, Rolf wrote:
>
>> Hi,
>>
>> My app has a borderless and transparent window. Various controls are
>> placed on this window, including a transluscent NSBox.
>> The NSBox must be click-through (ie mouse clicks must go to whatever
>> window lies behind it). All the other controls on the same window must
>> NOT be click-through, including those that are lying on top of the
>> NSBox.
>>
>> Anybody know how to acheive this ? The method must work on OS X 10.1
>> and upwards.
>>
>> NSWindow setIgnoresMouseEvents:TRUE will not work since it would also
>> make other controls than the NSBox click-through.
>> Maybe I could "redirect" mouse events coming to the NSBox to whatever
>> lies beneath it. I guess I could override sendEvent to fetch these,
>> but how would I redirect them to whatever lies behind ?
>>
>> Thanks.
>>
>> /Rolf
>> _______________________________________________
>> cocoa-dev mailing list | email@hidden
>> Help/Unsubscribe/Archives:
>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: How to use color in panther's Font Panel ?
  • Next by Date: Re: How to use color in panther's Font Panel ?
  • Previous by thread: Window with click-through areas
  • Next by thread: NSBrowser problems
  • Index(es):
    • Date
    • Thread