Examples of NSNotificationCenter


Examples of cli.MonoTouch.Foundation.NSNotificationCenter

                @Override public void Invoke (NSNotification nf) {
                    IOSNativeTextField field = _activeFields.get(nf.get_Object());
                    if (field != null) field.didFinish();
                }});

        NSNotificationCenter center = NSNotificationCenter.get_DefaultCenter();

        // observe UITextField
        center.AddObserver(UITextField.get_TextDidBeginEditingNotification(), didBegin);
        center.AddObserver(UITextField.get_TextFieldTextDidChangeNotification(), change);
        center.AddObserver(UITextField.get_TextDidEndEditingNotification(), didEnd);

        // observe UITextView
        center.AddObserver(UITextView.get_TextDidBeginEditingNotification(), didBegin);
        center.AddObserver(UITextView.get_TextDidChangeNotification(), change);
        center.AddObserver(UITextView.get_TextDidEndEditingNotification(), didEnd);

        // slide the game view up when the keyboard is displayed
        center.AddObserver(UIKeyboard.get_DidShowNotification(),
            new cli.System.Action$$00601_$$$_Lcli__MonoTouch__Foundation__NSNotification_$$$$_(new cli.System.Action$$00601_$$$_Lcli__MonoTouch__Foundation__NSNotification_$$$$_.Method() {
                @Override public void Invoke (NSNotification nf) {
                    if (_gameViewTransformed) {
                        // already transformed, bail with a warning
                        log.warning("Keyboard shown when already showing?", "viewTransform",
                                    _gameViewTransform);
                        return;
                    }

                    // find the first responder
                    IOSNativeTextField firstResponder = findFirstResponder();
                    if (firstResponder == null) return; // it's not a field we're managing, bail

                    // figure out how we need to transform the game view
                    SizeF size = ((NSValue) nf.get_UserInfo().get_Item(
                        UIKeyboard.get_FrameBeginUserInfoKey())).get_RectangleFValue().get_Size();
                    RectangleF fieldFrame = firstResponder.getView().get_Frame();
                    // oddly, the size given for keyboard dimensions is portrait, always.
                    float targetOffset = -size.get_Width() +
                        _overlay.get_Bounds().get_Height() - fieldFrame.get_Bottom();
                    // give it a little padding, and make sure we never move the game view down,
                    // also make sure we never move the bottom of the game view past the top of the
                    // keyboard
                    targetOffset = Math.max(Math.min(targetOffset - 10, 0), -size.get_Width());
                    PointF target = new PointF(0, targetOffset);
                    target = _overlay.get_Transform().TransformPoint(target);

                    // update and set the transform on the game view
                    UIView gameView = _overlay.get_Superview();
                    CGAffineTransform trans = gameView.get_Transform();
                    _gameViewTransform = trans.Invert().Invert(); // clone
                    trans.Translate(target.get_X(), target.get_Y());
                    gameView.set_Transform(trans);
                    _gameViewTransformed = true;

                    // touches outside of the keyboard will close the keyboard
                    _overlay.Add(_touchDetector);
                }}));

        center.AddObserver(UIKeyboard.get_WillHideNotification(),
            new cli.System.Action$$00601_$$$_Lcli__MonoTouch__Foundation__NSNotification_$$$$_(new cli.System.Action$$00601_$$$_Lcli__MonoTouch__Foundation__NSNotification_$$$$_.Method() {
                @Override public void Invoke (NSNotification nf) {
                    // bail if not transformed; this might be ok, if the keyboard was shown outside
                    // of our purview
                    if (!_gameViewTransformed) return;

                    UIView gameView = _overlay.get_Superview();
                    gameView.set_Transform(_gameViewTransform);
                    _gameViewTransform = null;
                    _gameViewTransformed = false;
                    _touchDetector.RemoveFromSuperview();
                    _platform._focus.update(null);
                }}));

        _currentOrientation = UIDevice.get_CurrentDevice().get_Orientation().Value;
        center.AddObserver(UIDevice.get_OrientationDidChangeNotification(),
            new cli.System.Action$$00601_$$$_Lcli__MonoTouch__Foundation__NSNotification_$$$$_(new cli.System.Action$$00601_$$$_Lcli__MonoTouch__Foundation__NSNotification_$$$$_.Method() {
                @Override
                public void Invoke (NSNotification nf) {
                    UIDeviceOrientation orient = UIDevice.get_CurrentDevice().get_Orientation();
                    if (orient.Value == _currentOrientation) return; // NOOP
View Full Code Here

Examples of com.webobjects.foundation.NSNotificationCenter

    }
    _registerForAdaptorContextNotifications();
  }

  public void _registerForAdaptorContextNotifications() {
    NSNotificationCenter notificationCenter = NSNotificationCenter.defaultCenter();
    notificationCenter.addObserver(this, ERXForwardingAdaptorContext._beginTransactionSelector, EOAdaptorContext.AdaptorContextBeginTransactionNotification, _forwardedContext);
    notificationCenter.addObserver(this, ERXForwardingAdaptorContext._commitTransactionSelector, EOAdaptorContext.AdaptorContextCommitTransactionNotification, _forwardedContext);
    notificationCenter.addObserver(this, ERXForwardingAdaptorContext._rollbackTransactionSelector, EOAdaptorContext.AdaptorContextRollbackTransactionNotification, _forwardedContext);
  }
View Full Code Here

Examples of com.webobjects.foundation.NSNotificationCenter

    notificationCenter.addObserver(this, ERXForwardingAdaptorContext._commitTransactionSelector, EOAdaptorContext.AdaptorContextCommitTransactionNotification, _forwardedContext);
    notificationCenter.addObserver(this, ERXForwardingAdaptorContext._rollbackTransactionSelector, EOAdaptorContext.AdaptorContextRollbackTransactionNotification, _forwardedContext);
  }

  public void _unregisterForAdaptorContextNotifications() {
    NSNotificationCenter notificationCenter = NSNotificationCenter.defaultCenter();
    notificationCenter.removeObserver(this, EOAdaptorContext.AdaptorContextBeginTransactionNotification, _forwardedContext);
    notificationCenter.removeObserver(this, EOAdaptorContext.AdaptorContextCommitTransactionNotification, _forwardedContext);
    notificationCenter.removeObserver(this, EOAdaptorContext.AdaptorContextRollbackTransactionNotification, _forwardedContext);
  }
View Full Code Here

Examples of com.webobjects.foundation.NSNotificationCenter

        }
    }


    protected static void initialize() {
        NSNotificationCenter center = NSNotificationCenter.defaultCenter();
        NSSelector sel = ERXSelectorUtilities.notificationSelector("updateTimestampForEditingContext");
        Observer observer = new Observer();
        ERXRetainer.retain(observer);
        center.addObserver(observer, sel, ERXExtensions.objectsWillChangeInEditingContext, null);
    }
View Full Code Here

Examples of com.webobjects.foundation.NSNotificationCenter

   * on the session's object store.
   *
   * @param session
   */
  protected void postNotification(ERXSession session) {
    NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
    nc.postNotification(MODERNIZR_UPDATED_NOTIFICATION, session);
  }
View Full Code Here

Examples of com.webobjects.foundation.NSNotificationCenter

    public void configureFactory() {
        // CHECKME: This might be better configured in a static init block of ERXValidationFactory.       
        ERXValidation.setPushChangesDefault(ERXValueUtilities.booleanValueWithDefault(ERXSystem.getProperty("er.extensions.ERXValidationShouldPushChangesToObject"), ERXValidation.DO_NOT_PUSH_INCORRECT_VALUE_ON_EO));

        if (WOApplication.application()!=null && !WOApplication.application().isCachingEnabled()) {
            NSNotificationCenter center = NSNotificationCenter.defaultCenter();
            center.addObserver(this,
                               new NSSelector("resetTemplateCache",  ERXConstant.NotificationClassArray),
                               ERXLocalizer.LocalizationDidResetNotification,
                               null);
        }
    }
View Full Code Here

Examples of com.webobjects.foundation.NSNotificationCenter

        }
        try {
          // NSLog.debug.appendln("Loaded items: " + initializedFrameworks);
            if(observer == null) {
                observer = new Observer();
                NSNotificationCenter center = NSNotificationCenter.defaultCenter();
                center.addObserver(observer,
                        new NSSelector("willFinishInitialization",  ERXConstant.NotificationClassArray),
                        // WOApplication.ApplicationWillFinishLaunchingNotification,
                        ERXApplication.ApplicationDidCreateNotification,
                        null);
                center.addObserver(observer,
                        new NSSelector("didFinishInitialization",  ERXConstant.NotificationClassArray),
                        // WOApplication.ApplicationWillFinishLaunchingNotification,
                        ERXApplication.ApplicationDidFinishInitializationNotification,
                        null);
            }
View Full Code Here

Examples of com.webobjects.foundation.NSNotificationCenter

   
    //Create the persistent session store
    WOApplication.application().setSessionStore(store);
   
    //Set up notifications for newly created sessions
    NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
    NSSelector<Void> sel = new NSSelector<Void>("enableSessionDistribution", new Class[] {NSNotification.class});
    nc.addObserver(this, sel, WOSession.SessionDidCreateNotification, null);
  }
View Full Code Here

Examples of com.webobjects.foundation.NSNotificationCenter

     * notification to the ec which still contains the eo in insertedObjects.
     *
     * When this happens, the ec throws an exception. To prevent this, the ec
     * is removed here as an observer for notifications when it is serialized.
     */
    NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
    nc.removeObserver(this);
  }
View Full Code Here

Examples of com.webobjects.foundation.NSNotificationCenter

    static {
        setUpFrameworkPrincipalClass(Ajax.class);
    }

    public Ajax() {
      NSNotificationCenter center = NSNotificationCenter.defaultCenter();
      // This is needed when ERXAjaxApplication is sub-classed
      center.addObserver(this,
          new NSSelector("finishAjaxInitialization", ERXConstant.NotificationClassArray),
          WOApplication.ApplicationWillFinishLaunchingNotification,
          null);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.