Page 1 of 2

focus button in one group scroll

Posted: Sat Feb 14, 2015 7:15 pm
by fko2
Hi,

I have one group with some buttons and images and i also can scroll in this group.
The problem i have is that when i press in any of the buttons belonging to this group nothing happens.

Finally i could see that if before to press in any button i move up or down with the scroll, then it will work well when i press in any of the buttons.

Is it one question of one "focus"? This is what i thought and i put in my code in the on openCard this line:

focus on group "grpCardW"

But nothing happened...The buttons are only working if before i scroll in this group...

Help please!

Kind regards,
fko

Re: focus button in one group scroll

Posted: Sat Feb 14, 2015 10:52 pm
by jacque
It might be due to the way the scroller is set up when you create it. Try playing with canCancelTouches and delayTouches settings in the handler. These determine how the scroller reacts to taps in the scroller when you aren't actually scrolling. I'm not sure what the default settings are if you don't specifically set them.

Re: focus button in one group scroll

Posted: Sun Feb 15, 2015 12:09 am
by fko2
Hi Jacque,

I tried this

Code: Select all

      mobileControlSet myScrollerID, "canCancelTouches", "false" -- "false" and "true"
and this

Code: Select all

      mobileControlSet myScrollerID, "delayTouches", "true" -- "false" and "true"
alone, or mixing both ( true and true, true and false, false and true, false and false)

Code: Select all

      mobileControlSet myScrollerID, "canCancelTouches", "false" -- "false" and "true"
      mobileControlSet myScrollerID, "delayTouches", "true" -- "false" and "true"
And in any of them i saw one different behavior.

Is this what you told me or not?
In the dictionary i could see that it is written "( iOS only )"...My target is to make it work also in Android...
It means that there is no solution for Android or maybe it means that it will work 'well' by default and the buttons will have the focus???
Anyway for the moment it didn't work, even for iOS...

Regards.
fko

Re: focus button in one group scroll

Posted: Sun Feb 15, 2015 6:54 am
by jacque
Yes, that's what I meant, it was the only thing I could think of. Android should interpret touches correctly by default, so it doesn't have those options.

If those don't work then I'm not sure why it behaves that way. Maybe someone else has an idea.

Edit: what is the handler you use to catch touches? Can you post it?

Re: focus button in one group scroll

Posted: Sun Feb 15, 2015 12:18 pm
by fko2
Hi,

This is my code ( or the code i saw in the lessons and other posts ) i am using concerning to movement and / or scrolling:
What you told me i put it in the 'openCard'.

Code: Select all

local hdiff,vdiff
local myScrollerID

on preopenCard
   set the unboundedVScroll of group "myGroup" to true
end preopenCard

on openCard
   if the environment is "mobile" then
      mobileControlCreate "scroller", "groupScroller"
      put the result into myScrollerID
      put the topLeft of group "myGroup" into tRect
      put the right of group "myGroup" into item 3 of tRect
      put the height of this card into item 4 of tRect
      
      put the formattedWidth of group "myGroup" into tWidth
      put the formattedHeight of group "myGroup" into tHeight
      mobileControlSet myScrollerID, "visible", "true"
      mobileControlSet myScrollerID,"rect", tRect
      mobileControlSet myScrollerID, "contentRect", (0,0,tWidth,tHeight)
      --mobileControlSet myScrollerID, "delayTouches", "true" 
      --mobileControlSet myScrollerID, "canCancelTouches", "false"

   end if

end openCard



on touchStart theID
   put item 1 of mouseLoc() into hdiff
   put item 2 of mouseLoc() into vdiff
end touchStart

on touchmove theID
   put item 1 of mouseLoc() into hdiffOffset
   put item 2 of mouseLoc() into vdiffOffset
   
   if hdiff < hdiffOffset AND ABS( hdiff - hdiffOffset) > 100 then
      send "swipedToRight" to me in 0 millisecs
   end if
   
   if hdiff > hdiffOffset AND ABS( hdiff - hdiffOffset) > 100  then
      send "swipedToLeft" to me in 0 millisecs
   end if
   
   if vdiff < vdiffOffset AND ABS( vdiff - vdiffOffset) > 100 then
     send "swipedToDown" to me in 0 millisecs
   end if
   
   if vdiff > vdiffOffset AND ABS( vdiff - vdiffOffset) > 100  then
     send "swipedToUp" to me in 0 millisecs
   end if
end touchmove


on scrollerDidScroll pHScroll, pVScroll
set the vScroll of group "myGroup" to pVScroll
end scrollerDidScroll


on closeCard
   if environment() = "mobile" then
      iphoneClearTouches
      mobileControlDelete "groupScroller"
   end if
end closeCard
Cool if for Android it should work well directly! :-)

Regards.
fko

Re: focus button in one group scroll

Posted: Sun Feb 15, 2015 6:57 pm
by jacque
I see. There is nothing in the script to manage taps, there is only code to manage scrolling. You need to add a touchEnd handler to catch taps. (You can alternately use a mouseUp handler, it's the same thing. But don't use both.)

Re: focus button in one group scroll

Posted: Sun Feb 15, 2015 7:56 pm
by Dixie
Hi...

I have attached a stack that scrolls a number of groups... 26 of them... each group contains a button that will return the letter associated with it when pressed... it might help you...:-)

Re: focus button in one group scroll

Posted: Mon Feb 16, 2015 4:33 pm
by fko2
Hi,

Thanks to both! :-)

Ok Jacque, I didn't know that i had to use one touchEnd...:-(

Thanks Dixie, i will also look at your example...It sounds perfect for what i am trying to do...:-)

Regards,
fko

Re: focus button in one group scroll

Posted: Mon Feb 16, 2015 5:11 pm
by fko2
Hi Dixie,

I looked at your code and i didn't see that you were using any touchEnd or mouseUp to control the taps as Jacque told me..:-(

It means that you are controlling these in this part of your code?

Code: Select all

   iphoneControlSet scrollID, "rect", theRect
   iphoneControlSet scrollID, "contentRect", theContentRect
   iphoneControlSet scrollID, "canBounce", "true"
   iphoneControlSet scrollID, "scrollingEnabled", "true"
   iphoneControlSet scrollID, "canScrollToTop", "true"
   iphoneControlSet scrollID, "lockDirection", "true"
   iphoneControlSet scrollID, "decelerationRate", "normal"
   iphoneControlSet scrollID, "pagingEnabled", "false"
   iphoneControlSet scrollID, "indicatorStyle", "black"
   iphoneControlSet scrollID, "vIndicator", "true"
   iphoneControlSet scrollID, "delayTouches", "true"
   iphoneControlSet scrollID, "canCancelTouches", "true"
   iphoneControlSet scrollID, "hscroll", 0
   iphoneControlSet scrollID, "visible", "true"
   iphoneControlSet scrollID, "vscroll", 0
and being more precise it should be in this part of your code that you are controlling this?

Code: Select all


   iphoneControlSet scrollID, "delayTouches", "true"
   iphoneControlSet scrollID, "canCancelTouches", "true"

This is what i am supposing, even if i am not 100% sure that it is because of these two lines...
So, if you are controlling this with these two lines, i am wondering why it is not working for me, as i already tried with these two lines ( i tried putting them to true- false, true - true, false - true and false- false ) in the code i posted the other day...:-(

Regards,
fko

Re: focus button in one group scroll

Posted: Mon Feb 16, 2015 7:05 pm
by fko2
Hi Dixie,

I tried copying all this

Code: Select all

   iphoneControlSet scrollID, "rect", theRect
   iphoneControlSet scrollID, "contentRect", theContentRect
   iphoneControlSet scrollID, "canBounce", "true"
   iphoneControlSet scrollID, "scrollingEnabled", "true"
   iphoneControlSet scrollID, "canScrollToTop", "true"
   iphoneControlSet scrollID, "lockDirection", "true"
   iphoneControlSet scrollID, "decelerationRate", "normal"
   iphoneControlSet scrollID, "pagingEnabled", "false"
   iphoneControlSet scrollID, "indicatorStyle", "black"
   iphoneControlSet scrollID, "vIndicator", "true"
   iphoneControlSet scrollID, "delayTouches", "true"
   iphoneControlSet scrollID, "canCancelTouches", "true"
   iphoneControlSet scrollID, "hscroll", 0
   iphoneControlSet scrollID, "visible", "true"
   iphoneControlSet scrollID, "vscroll", 0
and it worked...:-)

But only with this,

Code: Select all

   iphoneControlSet scrollID, "delayTouches", "true"
   iphoneControlSet scrollID, "canCancelTouches", "true"
and it is not working...

I looked in the dictionary and anyone of the other lines i discarded has ( in my opinion ) relationship with this...But without them is not working...:-(
Is one mystery for me, but ok...:-)

Regards.
fko

Re: focus button in one group scroll

Posted: Tue Feb 17, 2015 12:10 am
by fko2
Hi,

profiting that i was speaking about scrolling, i have one doubt. Till now what i made was with vertical scrolls and it worked well...
But in this case i am trying to one horizontal scroll...But it is not working.
Someone can tell me what is wrong in my code? I have one group created and the location is locked...

Code: Select all


local sScrollerIDWeek

on preopenCard
   set the unboundedHScroll of group "grpWeek" to true
end preopenCard


on openCard

   if the environment is "mobile" then
      mobileControlCreate "scroller", "groupScroller3"
      put the result into sScrollerIDWeek
      put the topLeft of group "grpWeek" into tRect
      put the right of group "grpWeek" into item 3 of tRect
      put the height of this card into item 4 of tRect
      
      put the formattedWidth of group "grpWeek" into tWidth
      put the formattedHeight of group "grpWeek" into tHeight
      mobileControlSet sScrollerIDWeek,"rect", tRect
      mobileControlSet sScrollerIDWeek, "contentRect", (0,0,tWidth,tHeight)
      mobileControlSet sScrollerIDWeek, "visible", "true"

      iphoneControlSet sScrollerIDWeek, "canBounce", "true"
      iphoneControlSet sScrollerIDWeek, "scrollingEnabled", "true"
      iphoneControlSet sScrollerIDWeek, "canScrollToTop", "false"
      iphoneControlSet sScrollerIDWeek, "lockDirection", "true"
      iphoneControlSet sScrollerIDWeek, "decelerationRate", "normal"
      iphoneControlSet sScrollerIDWeek, "pagingEnabled", "false"
      iphoneControlSet sScrollerIDWeek, "indicatorStyle", "black"
      iphoneControlSet sScrollerIDWeek, "hIndicator", "true"
      iphoneControlSet sScrollerIDWeek, "delayTouches", "true"
      iphoneControlSet sScrollerIDWeek, "canCancelTouches", "true"
      iphoneControlSet sScrollerIDWeek, "hscroll", 0
      iphoneControlSet sScrollerIDWeek, "vscroll", 0
  
   end if
end openCard



on scrollerDidScroll pHScroll, pVScroll
   set the hScroll of group "grpWeek" to pHScroll
end scrollerDidScroll

Thanks in advance! :-)

Regards.
fko

Re: focus button in one group scroll

Posted: Tue Feb 17, 2015 11:20 am
by fko2
Hi,

any help for my HScroll????

As i managed with one VScroll, i thought that i can also do it with one H...
But it is evident that i am doing something wrong...And i can't see where is my error in the last code i posted!!! :-(

Kind regards
fko

Re: focus button in one group scroll

Posted: Tue Feb 17, 2015 9:12 pm
by jacque
Is the group width smaller than the contents of the group?

Re: focus button in one group scroll

Posted: Wed Feb 18, 2015 11:44 am
by fko2
Hi Jacque,

The width of the group is 1759.
And the rect of my last element in this group is "1545, 475, 1765, 635"

Do you think that the problem is here?

Regards.
fko

Re: focus button in one group scroll

Posted: Wed Feb 18, 2015 6:29 pm
by fko2
Hi,

In fact i am doing the same as when i made one VScroll...
So i chooses all the elements i needed to put in my group and then i pressed on the 'Group selected' in the 'object' menu...
And then out one name to this group and locked the location.

So i am not touching the width or height of the group that are appearing automatically when i created the group...So, the same process as when i did it for the VScroll...But for the HScroll is not working...:-(

And as you asked me for the group width, then i decided to change it manually...So, in place of 1759, i made it 1859 to be sure that was bigger...But even like this is not working!

It means that my code for HScroll has no error?

Any help please?

Regards.
fko