dynamic text input

i wanna make more than one dynamic text in one scene to act as a user input field but when i enter any value in one the other is changed also is there a way around this ?

Can you provide a .blend? I can test it and see how to fix it.

i am having a problem with blender nw dont know where my fonts went :frowning:

Oh. Well, IDK what to tell ya. Maybe someone else will come and be more experienced.

dynamic_text.blend (684 KB) here is a simple blend file where there is two input boxes

dynamic_text.blend (684 KB) here is the .blend for two input boxes

Did you by chance duplicate the ‘first name’ text object and use it for ‘last name’?

yes i did but the problem is in the dynamic text and first name , last name is just a display is there another way to make a dynamic text and not give it a property Text ?

Nah, I tried. :frowning: Sorry. Maybe someone else more experienced will have a solution.

This depends how you implement that.

Usually you use an keyboard sensor to log the typed keys. [Be aware the keyboard sensor does not support keyboard mapping so it’s use is pretty limited when entering text).

Obviously you can fill one property only. This is no big deal as you want to enter one word at the time anyway.

What you need is a system to distribute the resulting value to other objects. Doing that is pretty simple:

def copyEnteredValueToText():
   enteredValue = getEnteredValue()
   focusedObject = getFocusedObject()
   setTextAt(focusedObject, enteredValue )

getEnteredText() just returns the value of the property you set up at he keyboard sensor:

def getEnteredText():
   owner = bge.logic.getCurrentController().owner
   return owner["property name that contains the entered text"]

getFocusedObject() is an important part to distributes the collected value to the currently focused object. e.g. the name field.
Here you need a way to determine which one it is. For example you could implement a selection system that allows you to retrieve the currently focused element from.
[attention: sample code]

def getFocusedObject():
   return mySelectionSystem.getSelectedObject()

setTextAt(), is much simpler, but you can have multiple solutions again.

def setTextAt(fontObject, value):
   fontObject.text = value

alternative to be used with Bitmaptext:

def setTextAt(bitmatTextObject, value):
   bitmatTextObject["Text"] = value

I hope you get the idea

i get the idea only one question i cant understand the get focused object function will getselected object get the object that i hit with my left button or how does it work ?

That is open as it depends on how you want to implement a selection operation.

I guess you currently have none. I can offer my own selection solution, but this will not help you to understand the concept. So lets think about it:

Select - mark objects as “selected” to differentiate it from “non-selected”
Focus - the same as Select but there can be only one at the time.

So you could implement a “Focus” system as special version of a “Selection” system.

The questions are the same:
How do you want to select/focus a single “text field” object?
(e.g. mouse point&click, <tab> whatever)

How should another object (in this case one with the keyboard sensor) get the selected/focus object?
(e.g. checking a known storage, searching the scene for objects with a certain criteria)

Any ideas?

i am thinking of messaging system that sends a message to the other field when i left click on the desired field but tried it and didnt do the trick

Ok than lets develop a selection system for you.

From your post I think I can assume you want the text field selectable by point&click.

I suggest to handle selecting of all objects the same way. This creates a consistent selection operation towards the user. The benefit to you is, you implement the logic just once rather than at all objects.

To do that you need a single object that cares of the selection. To allow us to easily find this object, I suggest you call it “Selection”. Usually it does not need to be visible, so an empty would be sufficient enough.

Should the text field know it is selected?
Should other objects get notified when the selection changed?
Should the selection handle objects of the current scene only, or all active scenes?

To do that you need a single object that cares of the selection. To allow us to easily find this object, I suggest you call it “Selection”. Usually it does not need to be visible, so an empty would be sufficient enough.

i cant understand this point where will the empty be ?

what i have so far two text field each has a keyboard sensor attached to it so how will it be one empty ?

Not to do a moderator’s job or anything, but I’m sure we would all appreciate it if you used the edit button in the future instead of double posting. Again, not trying to do a moderator’s job! I know my place :spin:

sorry its my mistake :slight_smile:

Common mistake, my friend! No harm no foul! :smiley:

Ok this will take to long. Have a look at this thread: Simple selection Selectionwith Logic Bricks. There you can find a demo.