1

I have code like following.

override func viewDidLoad() {
  super.viewDidLoad()   
  // Some setup    
  button.addTarget(self, action: #selector(handleInputModeList(from:with:)), for: .allTouchEvents)
}


override func handleInputModeList(from view: UIView, with event: UIEvent) {
  if event == onlyTouchUpEvent {
    // do something
  } else {
    super.handleInputModeList(from: view, with: event)
  }
}

In above handleInputModeList code, what to write in the if condition so that block only executes when the event is touchUpInside

Pavan Kumar
  • 1,715
  • 1
  • 24
  • 48

1 Answers1

0

func handleInputModeList(from: UIView, with: UIEvent) is to handle keyboard related events. Supports interaction with the list of user-enabled keyboards.

But you are trying to add UIControl.Event.touchUpInside.

You can do below to observe touchUpInside UIControl.Event

override func viewDidLoad() {
   super.viewDidLoad()   
   // Some setup    
   button.addTarget(self, action: #selector(handleInputTouchUpInside), for: .touchUpInside)
}


@objc func handleInputTouchUpInside() {
    print("UIControl.Event.touchUpInside")
}
Nandish
  • 1,136
  • 9
  • 16
  • 1
    Yes, right handleInputModeList is keyboard related event. I am trying to write customs keyboard. Each button in keyboard should behave differently depending on if it is touchupinside or longpress. Was wondering in event object passed as parameter has a determine event type. – Pavan Kumar Jul 19 '20 at 15:11