Trapping Touch Events in Browser Object
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Trapping Touch Events in Browser Object
I've been successful in loading a local PDF file for display using the ios native Browser object, but I can't seem to trap touch events on the browser object. I'm using the simulator. Touching (touch/drag/pinch) on the simulator all work well, but I can't do something as simple as trap a touchStart or touchEnd event. Any ideas how to go about this?
Thanks.
Joel
Thanks.
Joel
Re: Trapping Touch Events in Browser Object
Hi Joel,
Simply put, you have to trap the browserLoadRequest command.
Something like this:
Don't forget to add this line, though:
I don't know this works for you because you didn't clarify what you want to do by trapping touch events.
You may open a link which is embedded in the pdf in an in-app-browser with this method.
Or as a scenario which I use often,
you may have a full-screen html photo gallery page.
And to close the page and return back to the previous card,
you can place a close button inside the html of the photo gallery:
Then your trapped command would be like this:
Best,
~ Ender Nafi
Simply put, you have to trap the browserLoadRequest command.
Something like this:
Code: Select all
on browserLoadRequest pUrl, pType
# do your thing with pUrl
end browserLoadRequest
Code: Select all
mobileControlSet tControl, "delayRequests", true
I don't know this works for you because you didn't clarify what you want to do by trapping touch events.
You may open a link which is embedded in the pdf in an in-app-browser with this method.
Or as a scenario which I use often,
you may have a full-screen html photo gallery page.
And to close the page and return back to the previous card,
you can place a close button inside the html of the photo gallery:
Code: Select all
<a style="position: fixed; top:5px;left:5px;" href="closeThePage"><img style="border: none; width:64px; height:32px;" src="images/close.png"/></a>
Code: Select all
on browserLoadRequest pUrl, pType
if pUrl contains "closeThePage" then
visual effect push right fast
go to card sPreviousCard
end if
end browserLoadRequest
Best,
~ Ender Nafi
~... together, we're smarter ...~
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
Re: Trapping Touch Events in Browser Object
Ender,
Thanks for your response, although I'm still not sure if what you're suggesting works for my application.
I am working with PDF files that I display in the iOS Browser object. These are 'other peoples' files, so I am not creating them, but using my app to view them. There are many functions I wish to implement, but for starters I want to be able to simply trap a touch event in the Browser to that I can, for instance, toggle the display of menus using a 'tap' type of event. Even though LiveCode may not distinguish a tap from a touch, I can deal with that programmatically.
The other thing I want to be able to do is determine where, on a pdf, the use is touching, relative to the document origin.
Joel
Thanks for your response, although I'm still not sure if what you're suggesting works for my application.
I am working with PDF files that I display in the iOS Browser object. These are 'other peoples' files, so I am not creating them, but using my app to view them. There are many functions I wish to implement, but for starters I want to be able to simply trap a touch event in the Browser to that I can, for instance, toggle the display of menus using a 'tap' type of event. Even though LiveCode may not distinguish a tap from a touch, I can deal with that programmatically.
The other thing I want to be able to do is determine where, on a pdf, the use is touching, relative to the document origin.
Joel
Re: Trapping Touch Events in Browser Object
Hi Joel,
There isn't an easy way to get what you want.
Native browser object sends only these messages to the engine:
browserStartedLoading url
browserFinishedLoading url
browserLoadRequest url, type
browserLoadFailed url, error
browserLoadRequested url, type
according to the iOS Release Notes.
I'm not sure whether a workaround might be found.
It would be good, though.
'cause, I need this, too:
Best,
~ Ender Nafi
There isn't an easy way to get what you want.
Native browser object sends only these messages to the engine:
browserStartedLoading url
browserFinishedLoading url
browserLoadRequest url, type
browserLoadFailed url, error
browserLoadRequested url, type
according to the iOS Release Notes.
I'm not sure whether a workaround might be found.
It would be good, though.
'cause, I need this, too:
If you happen to find a solution/workaround, please share...toggle the display of menus using a 'tap' type of event...

Best,
~ Ender Nafi
~... together, we're smarter ...~
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
Re: Trapping Touch Events in Browser Object
Hi,
Are you two looking for the mouse loc within the browser rect?
Simon
Are you two looking for the mouse loc within the browser rect?
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Trapping Touch Events in Browser Object
Simon,
mouseLoc() is a function, right?
So in order to evaluate that function and build a code upon it,
first we have to place it inside a message, since in LiveCode it's all about messages.
Where do you suggest to place that function?
The native browser object, I mean the iOS Browser Object not revBrowser or anything, doesn't send any messages related to touch events.
That means, no matter how much or how hard you click within the rect of the browser, it doesn't fire any message which the coder can use.
It does only a couple of things:
* Zooming
* Scrolling
* Go to an url if the clicked portion of the screen consists a link
That's it and that's the problem...
Best,
~ Ender Nafi
mouseLoc() is a function, right?
So in order to evaluate that function and build a code upon it,
first we have to place it inside a message, since in LiveCode it's all about messages.
Where do you suggest to place that function?
The native browser object, I mean the iOS Browser Object not revBrowser or anything, doesn't send any messages related to touch events.
That means, no matter how much or how hard you click within the rect of the browser, it doesn't fire any message which the coder can use.
It does only a couple of things:
* Zooming
* Scrolling
* Go to an url if the clicked portion of the screen consists a link
That's it and that's the problem...
Best,
~ Ender Nafi
~... together, we're smarter ...~
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
Re: Trapping Touch Events in Browser Object
In the script of a substack who's:Where do you suggest to place that function?
blendlevel is 99
loc , hight, width = browser rect
windowshape = a grid with alpha
mode set to palette
Window Decorations = none
Don't know what will happen touchMove events.
Simon EDIT: Forget it windowshape is not supported in mobile. Oh Well, got close.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Trapping Touch Events in Browser Object
Hi,
You need to do all the trapping within HTML. From there you can send a URL request of some kind that can then be registered by LC. So you have a PDF reader in HTML that then has another layer above it that can collect info about the touch and either pass it on to the PDF reader and/or send a message onto LC coded with the mouse position, it's movement, and any other action you might want your LC script to be aware of etc.
If you need help with HTML5 then heres a good place to start: http://www.html5rocks.com/en/
All the best
Pi
You need to do all the trapping within HTML. From there you can send a URL request of some kind that can then be registered by LC. So you have a PDF reader in HTML that then has another layer above it that can collect info about the touch and either pass it on to the PDF reader and/or send a message onto LC coded with the mouse position, it's movement, and any other action you might want your LC script to be aware of etc.

If you need help with HTML5 then heres a good place to start: http://www.html5rocks.com/en/
All the best
Pi