- LiveCode Mobile Development Cookbook
- Dr Edward Lavieri
- 382字
- 2021-08-05 18:04:01
Recording user actions
Some applications are better served when you record the user's actions. In this context, a user action refers to an in-app behavior such as clicking on/touching a button or moving a slider. In this recipe, we will create a user action log and program a button to record user actions.
How to do it...
To record user actions, perform the following steps:
- Create a new main stack for a mobile application.
- Add three buttons across the top named
Safe
,Secure
, andRestricted
. - Add a button named
Reset Log
at the bottom-center of the card. - Create a scrolling text field named
fldLog
to fill the remainder of the card. - Set the background color of the
fldLog
field to black. - Set the foreground color of the
fldLog
field to yellow. This will be the color of the text entered into the log. - Set text size of the
fldLog
field to 14. - Set the
traversalOn
property tofalse
(deselect the Focusable checkbox in the Basic Properties section of the property inspector). - When you complete steps 1 to 5, your interface should look similar to the following screenshot. Make any adjustments to your four buttons and the scrolling text field before moving on to step 7.
- Add the following code to the card that contains your interface:
global logLine on preCardOpen put 1 into logLine end preCardOpen on updateLog msg2log put msg2log into line logLine of fld "fldLog" add 1 to logLine end updateLog
- Add the following code to the Reset Log button:
on mouseUp global logLine put 1 into logLine put empty into fld "fldLog" end mouseUp
- Add the following code to the Safe, Secure, and Restricted buttons:
on mouseUp updateLog(short name of me & ": mouseUp") end mouseUp on mouseDown updateLog(short name of me & ": mouseDown") end mouseDown on mouseEnter updateLog(short name of me & ": mouseEnter") end mouseEnter on mouseLeave updateLog(short name of me & ": mouseLeave") end mouseLeave
- Test your application. It should look similar to the following screenshot:
How it works...
By creating listeners (also known as handlers), we can record user actions in our apps. Depending upon your application, you might want to create a system log for security purposes or even to provide a display (as we did in our example) for users to review.
推薦閱讀
- 解析QUIC/HTTP3:未來互聯網的基石
- Mastering Machine Learning for Penetration Testing
- 從區塊鏈到Web3:構建未來互聯網生態
- 物聯網識別技術
- 走進物聯網
- 物聯網+BIM:構建數字孿生的未來
- Go Web Scraping Quick Start Guide
- Learning Swift(Second Edition)
- 中國互聯網發展報告2018
- 網絡基礎與網絡管理項目化教程
- OMNeT++與網絡仿真
- 小型局域網組建
- 物聯網M2M開發技術:基于無線CPU-Q26XX
- React Design Patterns and Best Practices(Second Edition)
- 區塊鏈技術與應用:打造分布式商業新生態