Tap status bar to scroll to top

Many native iOS apps that have a scrollview allow you to tap the top of the screen by the status bar, and the scrollview goes to the very top.  Twitter is a great example of this.

Any chance of this functionality being included in Corona?

It’s achievable on your own; you just need to:

  1. create a box where the status bar is

  2. set it to invisible, but allow touch

  3. attach a touch listener which can call :scrollToY or :scrollToIndex and then have it go where you like.

Go to top is not some kind of innate function of tableViews because it’s attached to the statusBar and not the widget.

Good solution Richard!

It’s achievable on your own; you just need to:

  1. create a box where the status bar is

  2. set it to invisible, but allow touch

  3. attach a touch listener which can call :scrollToY or :scrollToIndex and then have it go where you like.

Go to top is not some kind of innate function of tableViews because it’s attached to the statusBar and not the widget.

Good solution Richard!

I tried doing it this way but on iOS you can’t tap on anything behind the statusbar. It seems like the statusbar consumes all the touches. It works on the simulator but on iOS devices this solution fails to work. Haven’t tested Android yet.

Hi @Skatan,

I haven’t tested/confirmed this, but one possible solution is to use a Runtime touch/tap listener, and in its function, detect if the touch/tap Y position is within the range of the status bar. If so, take action, if not, return and ignore. Remember that the Y position will, of course, be related to the content size, so it’s not necessarily always between (say) 0 and 16. If you’re using “letterbox” scale mode and those letterbox bars are above and below the content area, the status bar may lie between -32 and -16 or something like that. Of course you can use the typical means to figure this out. :slight_smile:

Take care,

Brent

Hey Brent! Thanks for the tip, I haven’t tried that yet. Will give it a go and see if I can get it to work, thanks again! :slight_smile:

The Runtime method seems not work.
According to the post:

http://forums.coronalabs.com/topic/29051-how-to-make-status-bar-event/

it seems that status bar will natively block the touch, although the post is 1 year ago.

By the way, want to ask about the Runtime touch.

As I tested, the Runtime touch will be triggered after passing all display objects on the point user touched. That means if any object touch event at that point return true, Runtime event will not triggered. Am I right?

I had given it a try and got the exact same results. The status bar blocks the touch and Runtime touch appears to be behind all display objects. You can place an invisible rect on top of everything to track the touch but it still wouldn’t be detected behind the statusbar.

Can you go to http://feedback.coronalabs.com and see if there is an entry for this if not create one and get it voted up?

Rob

I tried doing it this way but on iOS you can’t tap on anything behind the statusbar. It seems like the statusbar consumes all the touches. It works on the simulator but on iOS devices this solution fails to work. Haven’t tested Android yet.

Hi @Skatan,

I haven’t tested/confirmed this, but one possible solution is to use a Runtime touch/tap listener, and in its function, detect if the touch/tap Y position is within the range of the status bar. If so, take action, if not, return and ignore. Remember that the Y position will, of course, be related to the content size, so it’s not necessarily always between (say) 0 and 16. If you’re using “letterbox” scale mode and those letterbox bars are above and below the content area, the status bar may lie between -32 and -16 or something like that. Of course you can use the typical means to figure this out. :slight_smile:

Take care,

Brent

Hey Brent! Thanks for the tip, I haven’t tried that yet. Will give it a go and see if I can get it to work, thanks again! :slight_smile:

The Runtime method seems not work.
According to the post:

http://forums.coronalabs.com/topic/29051-how-to-make-status-bar-event/

it seems that status bar will natively block the touch, although the post is 1 year ago.

By the way, want to ask about the Runtime touch.

As I tested, the Runtime touch will be triggered after passing all display objects on the point user touched. That means if any object touch event at that point return true, Runtime event will not triggered. Am I right?

I had given it a try and got the exact same results. The status bar blocks the touch and Runtime touch appears to be behind all display objects. You can place an invisible rect on top of everything to track the touch but it still wouldn’t be detected behind the statusbar.

Can you go to http://feedback.coronalabs.com and see if there is an entry for this if not create one and get it voted up?

Rob