Toggle button questions

Hello
in attached example i´ll use a toggle button to switch between 2 different input values, in one case with a additional little calculation. Basically it work :grinning:

two questions:

  • on start if no value is insert top right and i click/toggle button “Radiuseingabe in NM” to end in “Radiuseingabe in m” an error message is displayed. How can i prevent this?

  • if i have entered the value and confirm with softkeyboard “enter pressed” all is fine, but if i press the hardkey back button of my device softkeyboard disapeares and nothing happen.
    I´ve tried to solve this behavior with the “red marked Blocks” but with no sccess… assistance wanted

    Umrechnung_NM_m_toggle.aia (190.1 KB)

Komponente is a local variable. You cannot use it’s value outside the EnterPressed block unless you capture it’s value in a global variable. For example set a variable myKomponente = Komponente within the EnterPressed and THEN use myKomponente where you have your red cross (which indicates a coding error).

Try your toggle button blocks like this:

You do not need your screen back button blocks

thanks for your answers
@TIMAI2 now toggle button work without an error message :+1:
@SteveJG thanks for your advise but for now i can´t get it work sorry I’ve only been working with the MIT app inventor for a week…
my unsuccessful attempt

Try

I suspect my_Komponente =Komponente is what you should code.

Hi, Steve
basically i understand your suggestion, but unfortunately i haven’t found a way to put the code together yet.
for example: how can I combine the statements “set” and “get” with the function =?

or
where and how to insert the first example?

regardes Wolfgangcode

Uhoh. You can’t. Sorry, I assumed hole Komponente was a local variable. You are using an extension. It seems you need a Procedure to execute the code in your TaifunTextbox1.EnterPressed. I do not know it this is possible or you might need the contents of the TaifunTextbox or something else. I do not know. You might ask Taifun.

@Taifun
please can you take a look on part of my question in first post

if i have entered the value and confirm with softkeyboard “enter pressed” all is fine, but if i press the hardkey back button of my device softkeyboard disapeares and nothing happen.
I´ve tried to solve this behavior with the “red marked Blocks” but with no sccess… assistance wanted

after a discussion with @SteveJG my hope lies with you to find a solution

you could try to ignore the Screen.BackPressed event...
i.e. just drag an empty Screen.BackPressed event into the working area...

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

thanks for your answer, but it didn´t solve closing the softkeyboard

as workaround you might want to try to open the softkeyboard in the event Screen.BackPressed?
just use the RequestFocus method from a textbox
Taifun

softkey
basically it works but I have to press the back button two times until softkeyboard return.

here's an easier way https://medium.com/@paesser/how-to-create-a-toggle-switch-in-mit-app-invent-b3d67a984aa2