Spinner button click

Tom Law

Active Member
Licensed User
Longtime User
Can anyone tell me how to simulate a button click event on a spinner.

I have a datagrid that contains a spinner control, unfortunately the standard spinner button does not fit well and I would like to put a standard button on top of it. The problem I have is getting the standard button click event to trigger the spinner control .........

I'm sure that there must be some sort of performclick routine for a view but I can't find it.
 

Tom Law

Active Member
Licensed User
Longtime User
Hi Erel , thanks for replying. My intention would be to open up the spinner by clicking a secondary button (not the button that is built into the standard spinner).
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Globals
   Dim sp As Spinner
End Sub

Sub Activity_Create(FirstTime As Boolean)
   sp.Initialize("sp")
   sp.AddAll(Array As String("a", "b", "c", "d"))
   Activity.AddView(sp, 10dip, 10dip, 200dip, 50dip)
End Sub
Sub Activity_Click
   OpenSpinner(sp)
End Sub

Sub OpenSpinner(s As Spinner)
   Dim r As Reflector
   r.Target = s
   r.RunMethod("performClick")
End Sub
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Thanks Erel

Here:
B4X:
Sub Globals
   Dim sp As Spinner
End Sub

Sub Activity_Create(FirstTime As Boolean)
   sp.Initialize("sp")
   sp.AddAll(Array As String("a", "b", "c", "d"))
   Activity.AddView(sp, 10dip, 10dip, 200dip, 50dip)
End Sub
Sub Activity_Click
   OpenSpinner(sp)
End Sub

Sub OpenSpinner(s As Spinner)
   Dim r As Reflector
   r.Target = s
   r.RunMethod("performClick")
End Sub

Just what I was looking for
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
I just tried this approach to solve the same problem ... but not with 100% success.
My Spinners are set up using the designer.
The first time I click, the spinner panel opens on the far left of the screen running from top to bottom. Looks like an "automatic" placement and sizing is being imposed on it by the software. If I close it and reopen it, it appears where I planned for it.
Is there a similar approach that can be used to close the spinner all the way back up - both from a "wide open" position, and from a position where the spinner has been opened but not yet clicked to provide the dropdown?
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
Hi Erel,
Thanks for responding.
The code is buried in a much larger program. I have some more critical problems at this time, so I have decided to leave this item until later - or possibly not go that route, I'm not sure yet.

I'll come back to it with code if I need to find a solution.
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
Nice thought... but setting the focus to the spinner first didn't make any difference.
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
I would still like to be able to close the spinner by clicking on a different button - similar to the open method discussed, but to close up the spinner.
No itme selection or default vlue needs to be returned from the spinner. Is there a reflection method to do this?
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
But... Whenever you click on another view, be it a button or editText, the spinner will close...
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
But... Whenever you click on another view, be it a button or editText, the spinner will close...

You're absolutely right. I thought that this didn't apply in the operation I'm looking at but it turns out it does. So I'm good with that.
 
Upvote 0

Kbogle24

Member
Licensed User
Longtime User
I just tried this approach to solve the same problem ... but not with 100% success.
My Spinners are set up using the designer.
The first time I click, the spinner panel opens on the far left of the screen running from top to bottom. Looks like an "automatic" placement and sizing is being imposed on it by the software. If I close it and reopen it, it appears where I planned for it.
Is there a similar approach that can be used to close the spinner all the way back up - both from a "wide open" position, and from a position where the spinner has been opened but not yet clicked to provide the dropdown?

I had the same problem! what i did was place the spinner in a new panel and then moved the panel where I wanted to the spinner to open. Its a simple work around for now.
 
Upvote 0
Top