Chatbox with tooltip

I trying to make a C# script that allow user when press enter (which will open a textfield that allow user to type) and then if user click on an object, it will display the item name on the textfield. After the user press enter, it will close the textfield and then display it on a chatbox.

Now the question is how do i make it as tooltip when a user hover its mouse on the item name that is in the chatbox. If able, only on the item name only.

Example: I have a [sword].

Thus it will show the sword stats when the user move the mouse at word [sword].

So you have two variables here. You have a List that contains all the messages in the chatbox and you have a string for the chat message. You can use Physics.Raycast (check bottom example) to check if mouse is pointing at an object. Use LayerMask to filter out objects that are not of interest.
So when you’re pointing at a sword for example, you want to show hit.name in the textfield instead of your textfield string, when not pointing at the sword you’ll show the textfield string.