• 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: Help to understand how do events work
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help to understand how do events work


  • Subject: Re: Help to understand how do events work
  • From: "email@hidden" <email@hidden>
  • Date: Wed, 6 Oct 2010 13:36:02 +0100

On 6 Oct 2010, at 12:39, eveningnick eveningnick wrote:

> Hello!
> I have created a cocoa application that has unusual behavior: it has a
> window (NSPanel), which does not activate the application, when it's
> clicked. This window is ordered always on top of the other windows. So
> it's like a "tooltip" window (basically it is a popup thing, that
> drops down when a user types some combination of symols in another
> application - which is a texteditor).
> Anyway, i did it as following:
> NSPanel *popupWindow = [[NSPanel alloc]
> initWithContentRect:NSMakeRect(100,100,300,100)
> styleMask:NSNonactivatingPanelMask | NSTitledWindowMask
> backing:NSBackingStoreBuffered defer:NO];
> [popupWindow setLevel:NSPopupMenuWindowLevel];
>
> then i am showing it:
> [popupWindow makeKeyAndOrderFront:nil];
>
> This "window" behaves as expected: it is displayed on top of all
> others, even if it's Application (in Dock, for ex) is not active. It
> also dispatches all the clicks on controls (like NSPushButton's) to
> these controls.
>
> The problem for me is that i want to receive keyDown events with it.

Have a look at NSWindow -sendEvent:
If you subclass your window you can override  -sendEvent: and access the event stream like so:

/*

 send event

 This action method dispatches mouse and keyboard events sent to the window by the NSApplication object.

 */
- (void)sendEvent:(NSEvent *)event
{

	// look for key down
	if ([event type] == NSKeyDown) {

		// process the event

	}

	[super sendEvent:event];

}

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Help to understand how do events work (From: eveningnick eveningnick <email@hidden>)

  • Prev by Date: Re: Let the runloop process its queue during a long operation
  • Next by Date: Re: Let the runloop process its queue during a long operation
  • Previous by thread: Help to understand how do events work
  • Next by thread: Re: Help to understand how do events work
  • Index(es):
    • Date
    • Thread