Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended CopyLabel control #1

Open
Depechie opened this issue Jun 28, 2016 · 1 comment
Open

Extended CopyLabel control #1

Depechie opened this issue Jun 28, 2016 · 1 comment

Comments

@Depechie
Copy link

Would be great if the current implementation of the CopyLabel control ( in iOS project ) would have following extra extensions: highlight the label control with a given colour if the Copy popmenu is visible.

I've already tried to add this behaviour by adding following code in the private void OnLongPress(UIGestureRecognizer recognizer) method:

if (recognizer.State == UIGestureRecognizerState.Began)
{
    this.BackgroundColor = new UIColor(red: 0.78f, green: 0.78f, blue: 0.80f, alpha: 1.0f);

    BecomeFirstResponder();

    var copyMenu = UIMenuController.SharedMenuController;

    copyMenu.SetTargetRect(Bounds, this);
    copyMenu.ArrowDirection = UIMenuControllerArrowDirection.Default;
    copyMenu.SetMenuVisible(true, true);

    _notification = UIMenuController.Notifications.ObserveDidHideMenu((sender, args) =>
    {
        this.BackgroundColor = UIColor.Clear;
        _notification.Dispose();
    });
}

But somehow this doesn't seem 100% correct. Because by adding this code, on the first longpress I always get the ObserveDidHideMenu too ( and only the first time ).

So any tips on this?

@Depechie
Copy link
Author

Hmm could be this phenomenon is only in the iOS simulator... on an actual device the above code is working great.

Would be great if the highlight colour could be set through a property though... and also be set to the default iOS text highlight colour if nothing is provided in this property...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant