B4A Library Wheel by B4A Class

TrisectDevelopment

Active Member
Licensed User
Longtime User
I tried this in my App on the Wheel is working okay but not the _Roll event.
It just do not get called.

I implement the Wheel.bas file and use the following code:
B4X:
Dim wSetKilometer1 As Wheel
B4X:
wSetKilometer1.Initialize("main",svstep,True,"wc1", str1)
Activity.AddView(wSetKilometer1.AsView,0,170dip,80,svheight)
wSetKilometer1.SetAppearance(Colors.Yellow,Colors.Blue,16,Gravity.CENTER)

B4X:
Sub wc1_Roll(stepval As String)
    ToastMessageShow(stepval, False)
End Sub

The wc1_Roll event does not fire.
 

derez

Expert
Licensed User
Longtime User
Please check with version 2.1
(Usually you put event name like the object name so you can remember which is what, but it should work like you did).
The initialization in ver 2.1 is different.
Also - are you calling the class from Main or other activity ?
 
Last edited:

derez

Expert
Licensed User
Longtime User
No I'm not calling it from main, but from another activity.
Then the initialize command should have the activity name instead of "main".
B4X:
wSetKilometer1.Initialize("main",svstep,True,"wc1", str1)
 

Eldritch

Member
Licensed User
Longtime User
Hi Derez

In v2 how do you set cyclic when using the designer?

' cyclic - if the wheel is a loop or a line.

/Eldritch
 

derez

Expert
Licensed User
Longtime User
In the following code from the class:

B4X:
'Run by designer only
Private Sub DesignerCreateView(base As Panel, Lbl As Label, Props As Map)'ignore
mp = base
If Lbl.Text <> "" Then Wwheelstep = Lbl.text Else Wwheelstep = Lbl.Height/3.2
Wcyclic = Lbl.Visible
...
The Cyclic variable is set by the visibility of the label but this property does not exist in the designer, the visibility is for the base panel.
So currently there is no way to set non cyclic by the designer, since the default is true.
I'll have to modify it a little to add the functionality...
 

derez

Expert
Licensed User
Longtime User
Ver 2.2 provides addition to enable definition of cyclic in the designer, by this table:
 

Dario126

Member
Licensed User
Longtime User

This is beautiful upgrade on also very useful class.
Any pointers how to incorporate this into dialog, maybe inside custom dialog like BetterDialog http://www.b4x.com/android/forum/threads/lib-betterdialogs.30739/#content
 

Dario126

Member
Licensed User
Longtime User
I have seen that one, and your pointer to that is probably ok. Probably easiest way to "redesign" that one.

At first I disregarded because back panel was black, and fixed with no sub for changing. Code is not really commented and I was discouraged at first to change it. With some effort I was able to redesign it, but it's still not even close to your iPhone imitation. I still need to make paddings, and try some (blue transparent) panels like in your example ..

Anyhow, tnx ..

Btw. control like yours or Klauses, I would expect that is natively part of b4a .. unfortunately it's not :=(
 

luke2012

Well-Known Member
Licensed User
Longtime User

@derez is it possible to let the user choose the wheel value using Click event instead of TIP event ?
 

derez

Expert
Licensed User
Longtime User
is it possible to let the user choose the wheel value using Click event instead of TIP event ?
Please explain, I don't understand.
 

luke2012

Well-Known Member
Licensed User
Longtime User

Hi @AllanH,
my compliments! It looks great!
I understood that the wheel handle the _Roll event.
It's possible to handle also the _click or _touch event ?
 
Last edited:

derez

Expert
Licensed User
Longtime User
It's possible to handle also the _click or _touch event ?
You can modify the class to have a click event on the labels of the wheel, though I don't see a use for such method since the data had been provided when the wheel stopped.
Change this :
B4X:
Private Sub putlabels(n As Int)
For i = 0 To n-1
    lbw.initialize("lbl")
....

and add this:
B4X:
Private Sub lbl_click
If SubExists(Wmodule, WEventName & "_Roll") Then
  CallSub2(Wmodule,WEventName & "_Roll",Wvalues(newposition/Wwheelstep))
End If
End Sub

If you plan this event to do something else, I think you should not since the program will not know if you start a roll or a click.
 
Last edited:

luke2012

Well-Known Member
Licensed User
Longtime User

Thanks @derez!
My need is to let the user to select a value with the roll event and than "confirm" the selected value with a click.
Doing this the user click only hide the iWheel and the value selected il stored on a visible panel.
 

derez

Expert
Licensed User
Longtime User
put your confirmation code in a sub (in the calling module) and callsub this from sub lbl_click instead of what I wrote.
B4X:
Private Sub lbl_click
If SubExists(Wmodule, WEventName & "_Confirm") Then
  CallSub(Wmodule,WEventName & "_Confirm")
End If
End Sub
 
Last edited:

holdemadvantage

Active Member
Licensed User
Longtime User

Same results for me, method .SetByIndex and .SetByValue seems not working correctly ( i am trying THIS example), anyone has solved this issue?
 

derez

Expert
Licensed User
Longtime User
method .SetByIndex and .SetByValue seems not working correctly ( i am trying THISexample)
The examples use an old version of the class. Please check again with the last version.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…