B4A Library [Class]ClsWheel Input wheels

Attached you find a new CLASS ClsWheel.

It allows to display different data input screens with wheels.

What can be done ?
You can define nine different types of Wheel input screens:
  • DATE a date input : year / month / day
    A default value can be defined or Now, the current date.
    The returned value has the current DateFormat.
  • TIME_HM a time input : hour / minute
    A default value can be defined or Now, the current time.
    The returned value has the current TimeFormat.
  • TIME_HMS a time input : hour / minute / second
    A default value can be defined or Now, the current time.
    The returned value has the current TimeFormat.
  • DATE_TIME a date + time input : year / month / day / hour / minute
    A default value can be defined or Now, the current date and time.
    The returned value has the current DateFormat and TimeFormat.
  • CUSTOM a custom input with user defined input values.
    The number of side by side wheels is user defined (max. 5 wheels).
    A default value can be defined.
    A specific separation character can be defined, a blanc character is default.
  • INTEGER positive and negative integers
  • INTEGER_POS only positive integers
  • NUMBER positive and negative numbers
  • NUMBER_POS only positive numbers
Main functions:
Initialize initializes the wheel class Note: the Initialize routine hasone more parameter cContinusScrolling As Boolean (since version 1.3) .
Example :
whlDate.Initialize(Me, Activity, "Enter date", 3, Null, 24, 0, True)
Me = calling module, the current
Activity =
Enter date = title of the input
3 = number of wheels, this number is used only for CUSTOM input types
Null = no input data, set internally
24 = text size
0 = DATE input type
True = continus scrolling

Show show the input wheel(s)
Example :
whlDate.Show(lblSelection, "11/22/2001")
lblSelection = Label which gets the result
11/22/2001 = Default value to preset the wheels

Show2 show the input wheel(s)
Example :
whlCustum.Show2("whlCustom", "")
"whlCustom" = EventName
"" = no default value
The event is called 'Closed'.
The event routine in the calling module, for the example, must be
Sub whlCustom_Closed(Canceled As Boolean, Selection As String)

The width and height are defined by the program according to the font size.

If the width or the height exceed the screen width or height the font size is downscaled.

You can change most of the colors.

Needs the Reflection library.

Bug reports and suggestions are welcome.

I hope that the code is enough self explanatory, but if you want more explanations I can add them.
Anyway the best way to know what can be done is to test it.

PS. There is no logic in the custom input screen just to demonstrate the possibility.

Best regards.


EDIT: 2020.11.25 Version 2.7
Amended warning in line 946: Comparison of Object to other types will fail if exact types do not match.
EDIT: 2015.04.29 Version 2.0
Added a Tag property

EDIT: 2017.06.27 Version 2.6
Replaced DoEvents by Sleep(0)
Needs B4A version 7.00+

EDIT: 2017.03.30 Version 2.5
Amended the wish expressed HERE
Different font sizes for title and wheels.
With long titles, the font size of both, title and wheels, was reduced.
Now only the title font size is reduced.

EDIT: 2017.03.28 Version 2.4
Amended the error reported HERE
Problem with +/- in number wheels

EDIT: 2015.09.22 Version 2.3
Amended the error reported in post #185

EDIT: 2015.05.10 Version 2.2
Amended the variable declaration problem reported in post #175

EDIT: 2015.05.10 Version 2.1
Amended the timer problem reported in post #170

EDIT: 2014.09.09 Version 1.9
Added number wheels INTEGER, INTEGER_POS, NUMBER, NUMBER_POS wheels
Amended day scroll problem reported in post #141

EDIT: 2014.04.21 Version 1.7
Amended OutOfMemory problem reported HERE.

EDIT: 2013.09.15 Version 1.6
Added min MinYear and NumberOfYears properties to adapt the years to select

EDIT: 2013.08.08 Version 1.5
Added StartScroll and EdnScroll events

EDIT: 2013.06.14 Version 1.4
Modified OK event to Closed event post#37
Amended screen color problem post#36
Amendet getSeparationText error post #41

EDIT: 2013.06.12 Version 1.3
Mofied property routines.
Added Show2 for raising an event when clicking the OK button
Added optional continus scrolling

EDIT: 2013.05.28 Version 1.2
Amended the bug reported in post #32

EDIT: 2012.12.15 Version 1.1
Amended the reported bugs.
 

Attachments

  • Time_input.jpg
    Time_input.jpg
    32.9 KB · Views: 2,374
  • Custom_input.jpg
    Custom_input.jpg
    45.3 KB · Views: 2,305
  • ClsWheelV2_5.zip
    19.1 KB · Views: 563
  • ClsWheelV2_7.zip
    19.3 KB · Views: 590
Last edited:

aarondc

Member
Licensed User
Longtime User
@klaus

I have seen a scroll wheel that changes its text attribute (or maybe it's the background image) while scrolling, and restores it once scrolling stops. I'd like to try and emulate that.

Is it possible to process a "start scroll" / "end scroll" event for this view?

I already asked this, and it was missed, is there a better way of asking questions?
 

klaus

Expert
Licensed User
Longtime User
... is there a better way of asking questions?
You asked a simple question and you got a simple answer :).

I added the two events. The file has been updated in the first post.

To test it click on the 'With Event' button, when you scroll the activity title will show 'Scrolling'.

Best regards.
 

aarondc

Member
Licensed User
Longtime User
I am a simple B4Aer still!

Thank you, Klaus. I shall have a good look, much appreciated.
 

stefanoa

Active Member
Licensed User
Longtime User
NIce Class!!! ;)
but why it displays only the years from 2000 onwards? need for a birthdate (ex 1940)..
thanks
 

stefanoa

Active Member
Licensed User
Longtime User
thanks very much..
but i think there is a problem in new properties.
i'm trying to do:
B4X:
Dim tmpYear As Int = DateTime.GetYear(DateTime.Now) - 1900
whlDate.FirstYear = 1900
whlDate.NumberOfYears =tmpYear  'until current year
but don't work (the wheel does not work properly).

If instead i modify the class in:
B4X:
    Private cFirstYear = 1900 As Int  
    Private cNbYears = (DateTime.GetYear(DateTime.Now) - cFirstYear + 1) As Int
it work!
 

Espinosa4

Active Member
Licensed User
Longtime User
Hello everybody,

Can I change the date format in my screen?
I need that the first be day-month-year.

is it possible?

Thank you very much.
Espinosa
 
Last edited:

klaus

Expert
Licensed User
Longtime User
is it possible?
No, not in the current version.
The reason why I put it as year / month / day is the month of february and the different number of days in a month !
Selecting first the year the program knows if february has 28 or 29 days and then selecting the month the program knows how many days the selected month has this to update the last wheel for the days.

But anyway, the selected date is returned in the format you set in the program.

Best regards.
 
Last edited:

Espinosa4

Active Member
Licensed User
Longtime User
Ahhhhh, I understand now.
Thank you very much klaus.

Yes, I know I know, finally the result is Ok. It was only for esthetic reasons.

Cheers
Espinosa
 

stefanoa

Active Member
Licensed User
Longtime User
hi, i've this problem (images as attachment)

i've for ex. a edittext.text="21/9/2013" as date and when i execute for first time the whldata.show (pressing a button) it show "1/9/2013".
Then if i press cancel or Ok and re-press button (and so re-execute whldata.show) it show correctly "21/9/2013".

B4X:
whlDate.Initialize(Me, Activity, trans.GetText("Enter Date"), 3, Null, 24, 0, True)
...

If modGeneral.p_dateformatDDMMYYYY = True Then
   DateTime.DateFormat ="dd-MM-yyyy"
Else
   DateTime.DateFormat ="MM-dd-yyyy"
End If

    dateEditText.Text="21-09-2013"     '-- example
   
    Dim tmpData As String = dateEditText.Text.trim

    whlDate.Show(dateEditText,  tmpData)

what could be the cause?
 

Attachments

  • wh1.png
    wh1.png
    15.5 KB · Views: 256
  • wh2.png
    wh2.png
    35.6 KB · Views: 268
  • wh3.png
    wh3.png
    34.6 KB · Views: 247

stefanoa

Active Member
Licensed User
Longtime User
Yes, is initialized only one time in Activity_Create..
B4X:
whlDate.Initialize(Me, Activity, trans.GetText("Enter Date"), 3, Null, 24, 0, True)
whlTimeHM.Initialize(Me, Activity, trans.GetText("Enter Time"), 2, Null, 30, 1, True)

whlTimeHM, instead, work correctly... :(
 

klaus

Expert
Licensed User
Longtime User
Could you post your project as a zip file or at least a smaller one showing the problem.
I tested in the demo program your date and it works as expected.
But initializing whlDate each time I press the button I get the same as you do.

Best regards.
 
Top