Touch events

anaylor01

Well-Known Member
Licensed User
Longtime User
I am working on a panel that is going to have lines on it. I want to do something when the user click on a line. How would I set this up? Do I define the dimensions of each line? Do I use a case statement to determine each line? Each resolution is different so how could I program for that?
 

anaylor01

Well-Known Member
Licensed User
Longtime User
Another issue. When the checkbox is clicked it is not giving the correct checkbox number.
 

Attachments

  • Notes.zip
    32.9 KB · Views: 201
Upvote 0

klaus

Expert
Licensed User
Longtime User
Attached the modified version.

As agraham already posted, you must dim each CheckBox in the For/Next loop, line 180.
You must also dim cb in the cb_CheckedChange routine, line 196.

Best regards.
 

Attachments

  • Notes3.zip
    33.1 KB · Views: 205
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
I have two buttons that were added with code. The click event isn't working. I know it's something stupid. This is the first time I have worked with buttons added with code. So what am I missing? Its the lstsave button and the btndelete button. Line 666.
 

Attachments

  • Notes.zip
    33.3 KB · Views: 188
Upvote 0

klaus

Expert
Licensed User
Longtime User
When initializing a view by code you must specify the event name.
You initialized it, in line 147 with
lstsave.Initialize("")
but you must initialize it that way.
lstsave.Initialize("lstsave")
to get lstsave_Click

Best regards.
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Now I need to update the checkbox text. How do I tell the code which checkbox to update? Line 653. The checkboxes are an array so I am not sure how to do this.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You should add following routine:
B4X:
[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]GetCheckBox(Index [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b]Int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b]CheckBox[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  Return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] pnlTest.GetView(Index)[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

And you can access each CheckBox with its index beginning with 0.
B4X:
[FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]GetCheckBox([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]).Text = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Test22"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
Best regards.
 
Upvote 0

Helihead

Member
Licensed User
Longtime User
False touch events

Hey guys,

Not sure where to post this but this thread seems at least somewhat related to my issue....

I have an app built that uses around 10 different predesigned layouts. Each one uses a uniquely named panel as the base with all buttons, editboxes, labels, etc drawn on that and using the panel as its parent. I did it that way to make sure that each layout completely covered any layouts that were already loaded when I brought up a new one. There are no panel click, longclick or panel events coded.

Everything works fine except that when my fat finger can't accurately select a button or edittext or other control and lands partly on a control and partly on the panel it sometimes takes me off to some other page completely. I thought at first it was because I was seeing controls from other layouts behind the ones I just loaded but my base panels now cover everything behind them and they all have unique names. I also know it sometimes takes me to layouts that haven't even been purposefully loaded yet. When I try to duplicate the bug it is very inconsistent and either doesn't take me anywhere or takes me to various layouts at random.

Any idea why it often sends me off in strange directions when I don't click exactly?

Thanks
Jeff
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Not sure why it sends you off to places in the code that you are not expecting, but if the panel does not handle the click (or long click) event, the click will be passed on to any views under the panel.

The easiest solution is to define a click and a long click event for the panels (they can all point to the same sub), and simply have an empty sub. The system then sees that the click has been dealt with and will not pass it through.

For future reference it is better to start your own thread if you cannot find the answer to a question via a forum search. This ensures that the question can be found by other people with the same problem. Have a look at this helpful post for guidance :sign0089:
 
Upvote 0

Helihead

Member
Licensed User
Longtime User
[The easiest solution is to define a click and a long click event for the panels (they can all point to the same sub), and simply have an empty sub. The system then sees that the click has been dealt with and will not pass it through.]


OK that kind of makes sense based on what I think I am seeing. I will add those tonight and see if it traps the touch or clicks to the panel and kills em.

Thanks!
 
Upvote 0
Top