scrolling and clicking

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

scrolling and clicking

Post by BigameOver » Sat Mar 07, 2020 4:55 pm

Hi,
In my app there is a scrolling group. Inside the group there is a field.
When the user click on the field it should move him to another card but instead it doesnt work and it let him only scroll the group (field).
How can I make the program notice between clicking on the field and scrolling it?
thanks for the helping :D

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: scrolling and clicking

Post by Klaus » Sat Mar 07, 2020 5:17 pm

Hi BigameOver,

editable (= UNLOCKED) fields do not receive a "normal" mouseclick, only a right-click!
So maybe that is the probem?


Best

Klaus

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Re: scrolling and clicking

Post by BigameOver » Sat Mar 07, 2020 5:27 pm

Hi Klaus,
The app is only for android.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: scrolling and clicking

Post by Klaus » Sat Mar 07, 2020 5:35 pm

Same applies to this platform! :D
What did you script so far?
And is that namely field locked or not?
Are you using native scroller(s)?

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Re: scrolling and clicking

Post by BigameOver » Sat Mar 07, 2020 6:17 pm

I am attaching the file here
Attachments
scrolling problem.zip
(1.61 KiB) Downloaded 232 times

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: scrolling and clicking

Post by Klaus » Sat Mar 07, 2020 6:27 pm

Sorry, I don't own any mobile device (yes, no cellphone, that's me), so I cannot test your stack.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: scrolling and clicking

Post by dunbarx » Sat Mar 07, 2020 7:05 pm

Hi.

I commented out the lines restricting to mobil. The single field on cd 1 is not a scrolling field, so I made it one. The variable "sScrolling" is never "false", so the handler "touchTable" never fires. I changed it to:

Code: Select all

on mouseFakeUp
 --  if the environment is not "mobile" then exit mouseFakeUp
   if _sScrolling is true
   then
      put false into _sScrolling
  -- else
      send "touchTable" to field "chooseTable" of group "scrollerGroup" in 0 sec
   end if
   set the layerMode of me to "Static"
end mouseFakeUp
I also commented out this:

Code: Select all

   --  set the label of button "machinePicker" of card "mainCard" to the text of item tCell of line tLine of me
Because there is no button "machinePicker" anywhere. If there was, before the change to the "if/then" construction, an error would have been thrown when LC could not find that button.

So at least now a click in the field sends you to the next card.

But I am only fooling around here. It seems that what you want to do could instead be implemented in just a handful of lines of code in a single handler. But perhaps you are preparing for much additional functionality, and that is fine.

So can you give a rundown of the major gadgets you want from this app? And fix the things above and write back.

Craig

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Re: scrolling and clicking

Post by BigameOver » Sat Mar 07, 2020 7:57 pm

Hi dunbarx,
I think you didn't understand what I want.
I want the app to open the card "mainCard" if the user clicks on the group and doesn't scroll it.
If he scrolls the group, the app will not open this card.
However, thanks for the helping :D

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: scrolling and clicking

Post by dunbarx » Sat Mar 07, 2020 9:59 pm

Hmmm.

It was something I said. Oh yes:
So at least now a click in the field sends you to the next card.
Try this in a new stack. Make two cards. On card 1 make a scrolling field with enough lines of text in it so you have to scroll to see it all. Set the lockText of the field. Group the field (though this is not necessary at all). Put this into the field script:

Code: Select all

on mouseUp
   go cd 2
end mouseUp
The way scrolling fields are built, with the above one-liner, the body of the field will accept a "mouseUp" message, but the area of the scrollbar will not. So you can either scroll all day, or click and navigate.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: scrolling and clicking

Post by dunbarx » Sat Mar 07, 2020 10:03 pm

Hmmm, again.

Or was it important for you that the user be able to click in the actual scrollbar area, without moving the mouse, and navigate? This is not usual practice, but anything can be kluged.

Let me know...

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: scrolling and clicking

Post by jacque » Sun Mar 08, 2020 6:09 pm

The handler will be different depending on whether you are using a native mobile scroller or just a normal LC group. You won't get smooth scrolling with plain LC groups and the scrollbar is almost too small to use. Layout is also different depending on which method you use.

If you are using a native scroller, save the group scroll in a script local variable on mouseDown, and on mouseUp compare the scroll to the saved start position. If either the vscroll or the hscroll is less than 10 then it's a tap. (If 10 pixels isn't enough you can increase it slightly.) Native scrollers should be applied to the group, and the field inside the group needs to be as tall as the field's formattedHeight. If the group contains more objects than just the single field, you'll need to nest the grouped field inside the larger group and it gets a bit more complex.

Or are you using regular LC controls only? It's difficult to work with narrow scrollbars on mobile phones but if that's your choice then use mouseUp to detect a tap. The scrollbar will handle the scrolling without any scripting.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply