Inputbox that dont freeze timers?

techknight

Well-Known Member
Licensed User
Longtime User
Is there a custom inputbox that doesnt freeze the timers? my app requires to enter into an inputbox, problem is, that box pops up and pulls up the keyboard, it freezes the app and its timers.

any way around this?
 

drachmad

Member
Licensed User
Longtime User
It is not a full developed class!!! Just a simplified sample.
Actually the idea comes from Erel and Klaus class that I have mention above.
As you see the timer count (look at the log) is still counting while inputing the EditText.
Click at the button not the edit text!
 

Attachments

  • ClsDialog.zip
    8 KB · Views: 362
Upvote 0

gregwa

Member
Licensed User
Longtime User
Well, you could always create a psudo input box with a panel, text entry and button and maybe a label. Once the panel is created, you can set it's visibility to false until you need it, then when the button is clicked, you hide it again.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
This is the code I use:

Sub InputBox(Prompt As String, Title As String, Default As String, Hint As String) As String
Dim Id As InputDialog
Dim ret As Int
Id.Hint = Hint
Id.Input = Default
ret = Id.Show(Prompt, Title, "OK", "","CANCEL", Null)
If ret = -1 Then Return Id.Input Else Return ""
End Sub

Keeps it simple for me. But it stops the timer, trying to figure out how to make it not stop the timer.

the other problem is if i accidentally tilt the phone so it changes orientation, everything disappears. But I digress. Ill figure that out later.
 
Last edited:
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Also, Ill never use text. itll only be for numerical entry. So, if I can figure it out so it only pops up a number keyboard, thatll be great as well, Which I assume id.input is what specifies this?
 
Upvote 0

drachmad

Member
Licensed User
Longtime User
I have changed it to only accept numeric only and single line.
How many digits? if only one or two you can use the clsWheel.
The input dialog is a modal dialog, so it will stop the timer.
 

Attachments

  • ClsDialog.zip
    8 KB · Views: 280
Upvote 0

gregwa

Member
Licensed User
Longtime User
To answer the question about the type of edit text input type, you can set it for INPUT_TYPE_DECIMAL_NUMBERS or INPUT_TYPE_NUMBERS.
So if you are going for a non-modal panel solution, here is a quick code program that will work as an example using the Designer to do it.

Relevant code:

B4X:
Sub Globals
   '==========================
   ' From Activity Designer
   '==========================
   Dim btnGetInput As Button
   Dim btnOk As Button
   Dim EditText1 As EditText
   Dim lblInputResponse As Label
   Dim pnlInput As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("Layout1")
   pnlInput.Visible = False
End Sub

Sub btnGetInput_Click
   pnlInput.Visible = True
End Sub

Sub btnOk_Click
   lblInputResponse.Text = EditText1.Text
   pnlInput.Visible = False
End Sub

This of course assumes that you created an activity named "Layout1" using the designer. There are 6 views on the activity. A label named lblInputResponse to show the number entered in the "popup" panel, a button named btnGetInput which shows the panel, a panel which is set to .Visible = False that holds the other three views, a prompt label, an EditText view set to Input Type Numbers in the designer and an OK button that will fill the text of the lblInputResponse and hide the panel.

I've attached the prooject just as extra help. Sorry if it's too ugly, but I only took about 3 minutes to do it.

I hope it helps.
 

Attachments

  • InputPanelExample.zip
    7.2 KB · Views: 339
Upvote 0

gregwa

Member
Licensed User
Longtime User
As I was about to click the "Submit Reply" button on the previous post, my dog came up and nosed my elbow (he's a big dog) telling me that he wants to walk, which cause the mouse cursor to fly across the screen. When I was walking him, I thought that I should enhance the example to set the focus when the panel becomes visible and show the keyboard. So...
Add the IME library to your project...
In the Globals section, add the line:
B4X:
Dim ime1 as IME
In the Activity_Create routine add...
B4X:
ime1.Initialize("")
In the btnGetInput_Click routine add...
B4X:
EditText1.RequestFocus
ime1.ShowKeyboard(EditText1)
and if needed, in the btnOk_Click routine add...
B4X:
ime1.HideKeyboard
(This isn't needed on my device you you might want to put it in just in case.)

Using this route should not cause any issues with your timer.
Hope this helps.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
ok ill look into all these avenues to see which suits my needs. Really all I am using it for is to input numerical digits during runtime of the timers, etc...
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
I am trying to use the cInputBox class that was linked here.

I used this code to try and get it to numbers:

eb.cInputBoxEditText.InputType = eb.cInputBoxEditText.INPUT_TYPE_NUMBERS

Fails with null pointer exception. any ideas?
 
Upvote 0
Top