Author Topic: UIInput - Password  (Read 9717 times)

KChandra

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
UIInput - Password
« on: August 10, 2016, 11:11:07 AM »
Hi!

Is there a way to disable copy pasting values in a UIInput if the Input Type is set to Password?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput - Password
« Reply #1 on: August 10, 2016, 11:24:03 AM »
Yes. You can create a class derived from UIInput and overwrite the ProcessEvent function. The paste happens if the keycode is "c", on line 1072. You can check for that and exit out early if it's a password field.
  1. public override ProcessEvent (Event ev)
  2. {
  3.     if (ev.keyCode == KeyCode.C && inputType == InputType.Password) return;
  4.     base.ProcessEvent(ev);
  5. }

KChandra

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UIInput - Password
« Reply #2 on: August 11, 2016, 02:27:22 AM »
Ah cool! Thank you so much! :D

Fabien

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIInput - Password
« Reply #3 on: July 10, 2017, 08:51:26 AM »
Hi,

I had the same issue (and I will use the solution below), but I don't understand why it's not the default behaviour, it's very strange and uncommon that you can copy a "******" value.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput - Password
« Reply #4 on: July 15, 2017, 06:12:11 AM »
Well, you're the one typing it -- you know what you're typing, so why not allow copy/paste? :P