Putting a script that implements IPointerDownHandler on a Text means you can't type there?

How do I fix that? Disabling the script makes it visually click again (interactable). Very weird. I took a quick look at the parameter PointerEventData and didn’t see anything I could set to fix it?

Something similar happens if I put that script on a text field (can’t type there anymore until I disable or remove the script).

I’m using this asset from the store by Unity for testing: Unity Asset Store - The Best Assets for Game Making

My class implements IPointerDownHandler and has a method like this:

public void OnPointerDown (PointerEventData data) {
   Debug.Log("down");
}

I just did this:

using UnityEngine;
using UnityEngine.EventSystems;

public class TestScript : MonoBehaviour, IPointerDownHandler
{
    // Trigger all registered callbacks.
    public virtual void OnPointerDown(PointerEventData eventData)
    {
        Debug.Log ("down");
    }
}

And it works properly when attached to a button.

Thanks for the response. Ok I checked again and right, that does work. It looks like what I actually did was: there’s a child game object of the Button game object that has a Text component. Now if you put that same script on the game object with the Text component, you can no longer click there to type things. That seems to go for all Text components regardless of hierarchy.

Is that a bug, or expected behavior? Is there something I can do to still type there? Renaming the thread for the real issue.

It’s expected behaviour. The click goes to the element MOST valid to receive it. In your case it’s the text as it can handle the click. If the text can’t handle the click we look UP the tree for the thing that is valid to handle it.

I don’t think you understand what is happening. I said if I put a script on a Text game object, you can’t actually type in that text component anymore. The script with IPointerDownHandler prevents you from being able to type in the text field. That doesn’t seem normal to me.

@jerotas : can you show me your hierarchy ? I don’t really understand what you wanna do.

I mean, you’re talking about the Text component and typing on that component… but you can’t do that, Text component is just a “label”. You should use InputField component.

Maybe I’m missing something, this is why I need to see your project hierarchy.

Ok, you’re right about that part (Input Field). The Text is just the watermarked “Type something…” text. Here’s a screenshot. Notice I have the game object “Text” highlighted in the Hierarchy. If I put a script on it that implements IPointerDownHandler, you can no longer click on its parent (InputArea) and type anything. I’m not sure why you would want to put a script on the Text game object, but it still seems like a bug, not being able to type into the Input Field. Is it?

If I put that same script on the Input Field instead, I can click there and type. Which would suit my purposes fine. I’m just worried that one of my users may put a script on the wrong game object and wonder why they can’t type any more.

1875411--120546--upload_2014-12-5_18-19-57.jpg

Do you have the last version of Unity 4.6 ? Because it works well on my computer:

using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;

public class mytest : MonoBehaviour, IPointerDownHandler {
    public void OnPointerDown(PointerEventData data) {
        Debug.Log("CLICK AND TYPE");
    }
}

I have the only released version of 4.6 (unless there has been a hotfix I didn’t know about). Not the beta. It definitely doesn’t work on my machine. Click on the input field, type, nothing happens. Disable the script, it works. I can’t see your Hierarchy so it may not be the same test. I was using that example UI project you can download. It isn’t just a Text, but has an input as a parent and some other stuff.

You can see my hierarchy on the screen (bottom right). I’m gonna try on the UI Project, I need to download it.

Okay, got it. I guess there is a bug in their scene. If can only type “a” in the input. I can’t explain why :confused:

Maybe the bug comes from their Navigation system (sometime it focuses on another UI element (the slider, the scrollview and the large text input)).

Ok cool, I’m not crazy :slight_smile: Thanks.