Skip to content

Extended CopyLabel control #1

@Depechie

Description

@Depechie

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions