one numeric keypad for multiple text fields

  1. 2 months ago

    I'm still working on my first Xojo project, so forgive my lack of knowledge on the subject.

    I have multiple text fields on a window and buttons for numbers 0 - 9. The action of each button is something like

    TheEditField.Text = TheEditField.Text + Me.Caption

    but obviously it isn't correct because I'm lost. The user will tap the appropriate text field, then tap the number buttons to enter data into the selected text field. They repeat the process for any of the text fields they need to utilize. I don't know how to refer to the actual text field the user previously selected to append the new number.
    Any suggestions to get me headed in the correct direction?

    Note: This will be on a Raspberry Pi with a 7" vertical touchscreen. No keyboard. The keys on the inclueded virtual keyboard are so small that only toddlers can use it, so that option is out.

    Thanks in advance!

    It's not clear what you are trying to achieve, but I assume you want to add text from each button to the last selected textField? But how do you keep track of which TextField is supposed to get the caption added?

    Your problem is that when the user taps the button, then the textField looses the focus, so you need to keep track of where you want the caption to appear.

    So add a property SelectedTextField as TextField to the window

    In each TextFields GotFocus event write SelectedTextField = me

    In the Button's Action event write SelectedTextField.AppendText me.Caption

  2. Dave S

    Aug 9 San Diego, California USA

    Use controlsets to group all your text areas together so they can share events/methods
    Use AppendText

  3. Markus W

    Aug 9 Pre-Release Testers, Xojo Pro Answer #JeSuisHuman Germany, Heidelb...
    Edited 2 months ago

    It's not clear what you are trying to achieve, but I assume you want to add text from each button to the last selected textField? But how do you keep track of which TextField is supposed to get the caption added?

    Your problem is that when the user taps the button, then the textField looses the focus, so you need to keep track of where you want the caption to appear.

    So add a property SelectedTextField as TextField to the window

    In each TextFields GotFocus event write SelectedTextField = me

    In the Button's Action event write SelectedTextField.AppendText me.Caption

  4. I was so close to Markus' answer. I had my property as a control when it needed to be a textfield.
    I also did not know about appendtext so thanks to both of you!

or Sign Up to reply!