Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[iOS] Add ability to toggle selector actions on and off when an input field is long clicked #498

Closed
wants to merge 16 commits into from
Closed

Conversation

adrianknight89
Copy link
Contributor

@adrianknight89 adrianknight89 commented Nov 2, 2016

Description of Change

There is no way on iOS to disable selector actions when an input field is long clicked. This functionality may be needed in cases such as when preventing users from editing a password entry via the clipboard. I wanted to implement the same behavior on Android, but AppCompat seems to be ignoring all efforts. For now, it's left for another time.

This feature is currently implemented for Entry, Picker, TimePicker, and DatePicker.

Bugs Fixed

API Changes

Added:

  • 6 methods and 1 property for each class
  • SelectorAction enum

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense

SelectAll,
Share
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If more actions are needed to be available, this enum can be edited in the future.

}

class UITextFieldWrapper : UITextField
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CanPerform does not work unless UITextField is subclassed; hence the wrapper.

if (e.OldElement != null)
{
UnregisterEvents();
}
Copy link
Contributor Author

@adrianknight89 adrianknight89 Nov 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On each platform, we're checking old element, setting _noCaretField (down below), and implementing dispose for consistency.

return config;
}

public static IPlatformElementConfiguration<iOS, FormsElement> EnableDisabledSelectorActions(this IPlatformElementConfiguration<iOS, FormsElement> config)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just key on them setting/disabling the actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I'm misunderstanding you, but SelectorAction.All should disable all actions. This would be the default behavior of this method if the list is empty. If it is not empty, it doesn't change anything. Do you mean I should add all actions to the list when this method is called?

@jassmith
Copy link

We really like the ideas expressed in this PR, unfortunately we also feel it belongs in a community driven effect library which is not currently possible to make due to the need to override methods on a UIKit object. Therefor we are looking into options to make this possible so that we can avoid having every edge case PlatformSpecific end up in core and instead allow them to become independent nugets which can move and change (and break compat) much more freely.

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

Successfully merging this pull request may close these issues.

4 participants