Skip navigation.
 
mlInteresting WebView/NSRunLoop issue
FROM : David Springer
DATE : Thu Apr 24 19:35:36 2008

Folks,

I need help figuring out this problem.  Basically, I want to run a
WebView in a modal dialog, but WebView's don't work in
NSModalPanelRunLoopMode.  So, I have been trying unsuccessfully to
fake a modal run loop while running it in NSDefaultRunLoopMode.  This
is my latest attempt:

  // Leave all appkit defined and system events on the queue.  This will make
  // sure the app activates correctly when running this loop from within
  // -applicationDidFinishLaunching.
  unsigned int eventMask = NSAnyEventMask &
      ~(NSAppKitDefinedMask|NSSystemDefinedMask|
        NSApplicationDefinedMask|NSPeriodicMask);
  while (inModalLoop_) {
    NSEvent *event = [NSApp nextEventMatchingMask:eventMask
                                        untilDate:[NSDate distantFuture]
                                          inMode:NSDefaultRunLoopMode
                                          dequeue:YES];
    if (event != nil && [event window] == window_) {
      [NSApp sendEvent:event];
    }
  }

|inModalLoop_| is set to FALSE when the "modal" panel is dismissed.
Several problems arise with this method:

1. I want my app to effectively stall - that is, don't process any
events - while this modal window is up.
2. The modal window is ordered onscreen during
-applicationDidFinishLaunching:, so even though I want event
processing to appear modal to the window, I still need to let certain
events through so that the app will continue to activate correctly,
etc. once the panel is dismissed.
3. On Tiger, my method produces all kids of odd behavior, such as
button clicks in the window not causing notifications to get sent
(windowDidClose: in particular).

Basically, it appears that my method screws up the event system pretty badly.

Clearly my approach is bogus.  Should I be using a runloop for this?
If so, what mode do I run it in?

Help?

Thanks!
- Dave.S

Related mailsAuthorDate
No related mails found.