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,007
  • Custom_input.jpg
    Custom_input.jpg
    45.3 KB · Views: 1,916
  • ClsWheelV2_5.zip
    19.1 KB · Views: 232
  • ClsWheelV2_7.zip
    19.3 KB · Views: 175
Last edited:

tcgoh

Active Member
Licensed User
Hi,

Thanks for the very nice clswheel class, but I have some problem with date time now.

When I set clswheel.show(lbltext, ""), I will get the today's date on first time the clswheel was shown, but when I click the cancel button follow by the back button to get out of the App, the next time the clswheel will show a date on the 1st day of the month and not today's date.

Anyone has this problem?

Thanks for any help.
 

tcgoh

Active Member
Licensed User
Hi Klaus,

Thank you for the quick update to version 1.9, but I have problem opening the ClsWheelsV1_9.b4a with the this error,(I'm using B4a version 3.0)
upload_2014-9-9_18-39-4.png
 
Last edited:

klaus

Expert
Licensed User
Well, I use version 3.82.
Try the attached version, it is modified for B4A version 3.00.
EDIT :
Removed the zip file, look at the new one in post #146.
 
Last edited:

tcgoh

Active Member
Licensed User
Hi Klaus,

Thanks for coming up with a version for B4a Ver 3.0 But the attached version still has the same error about "given key was not present in dictionary"

Regards
 

klaus

Expert
Licensed User
Sorry, it seems that I messed up something.
Attached a correct version.
EDIT: *.bal files added.
 

Attachments

  • ClsWheelV1_9__3_00.zip
    18.6 KB · Views: 88
Last edited:

tcgoh

Active Member
Licensed User
Many Thanks again Klaus, now its working on b4a ver 3.0. BTW main.bal and numbers.bal are missing in the attachment, but I managed to copy from the earlier attachment.

Thanks again great work.
Regards
 

LucaMs

Expert
Licensed User
Hi, Fully great Klaus :),

I get an error at compilation time:

scvWheel(i).ScrollToNow(ScrollPos(i))

scvWheel(i) does not have the ScrollToNow member (it is a ScrollView)


[EDIT: I found this bad :) info:

15.png
ScrollToNow (Scroll As Int)

Immediately scrolls the ScrollView (with no animations).


Evidently this member was added after my B4A version (3.0).

Could you specify the difference compared to "scrollPosition"?]


Many thanks, Klaus
 
Last edited:

klaus

Expert
Licensed User
Whereever you see scvWheel(x).ScrollToNow(y)
replace it by objWheel(x).RunMethod3("scrollTo", 0, "java.lang.int", y, "java.lang.int")
You must replace x and y by the correct values.
ScrollPosition = X is equal to smoothScrollTo, smooth scroll
ScrollToNow(X) is equal to scrollTo, fast scroll
 

LucaMs

Expert
Licensed User
Whereever you see scvWheel(x).ScrollToNow(y)
replace it by objWheel(x).RunMethod3("scrollTo", 0, "java.lang.int", y, "java.lang.int")
You must replace x and y by the correct values.
ScrollPosition = X is equal to smoothScrollTo, smooth scroll
ScrollToNow(X) is equal to scrollTo, fast scroll

Many thanks, Klaus, I'll try.

The documentation is very brief; I have tried to use scrollPosition instead of ScrollToNow and a strange thing happens, I do not know if it is due to this.

If I select a day> 9 and then I select a month, day changes (it seems to me that it will become the number of the month).


Thanks again.
 

Attachments

  • lm ClsWheelsV1_9 Test.zip
    20.3 KB · Views: 64

klaus

Expert
Licensed User
The problem you encounter is not related to the scroll change.
It happens also in older versions.
I had never encountered it because I set first the year then the month and at last the day.
The problem is that the day list changes when you change the month because of the different numbers of days depending on the month.
That was the reason why the wheel layout is year - month - day.
 

LucaMs

Expert
Licensed User
I looked at the code.
If the reason is not the scroll but the calculation of the days, the problem should occur with any version of B4A.
(among other things, the order should be flexible, because the year / month / day is not usual).

I will try to go crazy modifying it :confused: :D

Thanks, Klaus
 

LucaMs

Expert
Licensed User
Damn, it was a mini-micro-little bug :)

I have different number lines, so I can't write the right one.

After:
B4X:
    Else If (WheelType = DATE OR WheelType = DATE_TIME) AND S = scvWheel(2) Then


there is:
B4X:
        CurrentDayIndex = Floor(scvWheel(1).ScrollPosition / lblHeight + 0.5) - WheelContentNb(1)


but the wheel of day has index 2.
B4X:
        CurrentDayIndex = Floor(scvWheel(2).ScrollPosition / lblHeight + 0.5) - WheelContentNb(2)



(I have not done a lot of tests, but it seems logical)
 
Top