A method, system, terminal, and medium for H5 page responding to touch operations

By encapsulating the touch type logic of native applications into JS functions within the operating system, and utilizing a bridging layer and machine learning models, the problem of WebView components being unable to correctly distinguish between gestures and styluses was solved, achieving accurate touch type recognition for H5 pages and optimization of system resources.

CN120491880BActive Publication Date: 2026-11-17INSPUR ZHUOSHU BIG DATA IND DEV CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510524830.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2026-11-17
Estimated Expiration
2045-04-24

AI Technical Summary

Technical Problem

In the operating system, the WebView component cannot correctly distinguish between gestures and stylus input, causing the H5 page to fail to accurately recognize the touch type, which affects the user interaction experience and system resource allocation.

Method used

The logic for distinguishing touch types in native applications is encapsulated into a JS function and exposed to the H5 page through a bridging layer. Combined with machine learning models and pressure threshold judgment, accurate distinction of touch types can be achieved.

Benefits of technology

It improves the accuracy and reliability of H5 pages in determining touch types, reduces redundant development costs, and enables low-latency data transfer and dynamic optimization of system resources between the native layer and H5 pages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120491880B_ABST
    Figure CN120491880B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of operating system processing technology, specifically disclosing a method, system, terminal, and medium for H5 pages to respond to touch operations. The method includes encapsulating the touch type differentiation logic of the native application into a JS function; constructing a bridging layer to expose the JS function to the H5 page, including registering a class on the native application side, declaring a property and a method in the class, where the property stores the operation parameters required to execute the JS function, and the method calls the JS function; when the user performs an operation, the native application side obtains the operation parameters and stores them in the class's property, the H5 page calls the JS function through the bridging layer, obtains the current touch type based on the operation parameters, and triggers the corresponding operation or interface feedback according to the current touch type. This invention can accurately distinguish between gestures and styluses, improving the accuracy and reliability of input judgment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of operating system processing technology, specifically relating to a method, system, terminal, and medium for H5 page responding to touch operations. Background Technology

[0002] Differentiating between gesture and stylus input offers several advantages in native operating system applications. Users can interact with the device in the most natural way, whether through gestures for global operations or precise stylus control. This diverse input method adapts to different scenario needs, improving user satisfaction. By differentiating between different types of input, applications can respond quickly to user intent. For example, a stylus might be used for high-precision operations such as selecting text and drawing; while gestures can be used for broader interactive behaviors such as zooming, rotating, and swiping, greatly improving efficiency. System resources can be allocated rationally based on the input type. For example, for stylus inputs requiring higher computing power (such as pressure sensing), their performance can be prioritized to ensure accuracy and timeliness of operations.

[0003] In operating systems, differentiating between gestures and styluses not only enhances the user experience but also provides developers with more flexible design options. In actual development, an H5 page is first loaded into a WebView component, where a canvas area is set up for touch type detection, aiming to determine whether the touch type is a hand touch or a stylus stroke. This method yields a stylus stroke result in the default browser, but in the native application's WebView component, it returns a touch, i.e., a hand touch. How to obtain the correct touch type on the H5 page within the WebView becomes a pressing issue. Summary of the Invention

[0004] To address the aforementioned issues, this invention provides a method, system, terminal, and medium for responding to touch operations on an H5 page, thereby improving the accuracy of obtaining the correct touch type on the H5 page.

[0005] In a first aspect, the technical solution of the present invention provides a method for H5 page to respond to touch operations, comprising the following steps: The logic for differentiating touch types in native applications is encapsulated into a JS function; Construct a bridging layer to expose JS functions to H5 pages. This includes registering a class on the native application side, declaring a property and a method in the class. The property is used to store the operation parameters required to execute the JS function, and the method is used to call the JS function. When a user performs an action, the native application obtains the action parameters and stores them in the class's properties. The H5 page calls a JS function through the bridge layer, obtains the current touch type based on the action parameters, and triggers the corresponding action or interface feedback according to the current touch type.

[0006] In an optional implementation, when a user performs an operation, the native application retrieves the operation parameters and stores them in a class attribute, specifically including: Pre-set event listeners to monitor stylus-related events and gesture input-related events; When the event listener is triggered, it extracts operation parameters from the listened stylus-related events and gesture input-related events. Store the operation parameters in the class's properties.

[0007] In an optional implementation, the H5 page calls a JS function through a bridging layer to obtain the current touch type based on the operation parameters, specifically including: Extract operation parameters from class attributes; The operation parameters are used as input to a JS function, which is then executed to obtain the current touch type.

[0008] In one optional implementation, the operating parameters include coordinate sequence, pressure value, timestamp, touch area, and tilt angle; The operation parameters are used as input to a JS function, which is then executed to obtain the current touch type, specifically including: Calculate velocity and acceleration based on coordinate sequence and timestamp, using operation parameters, velocity, and acceleration as input data; The touch trajectory is divided according to a preset time window, and the input data of each time window is converted into a feature vector; Retrieve a pre-trained touch type discrimination model, input each feature vector into the touch type discrimination model to obtain the probability that the current operation belongs to two touch types; touch types include stylus type and gesture input type; Detect whether the probability of a larger probability among various touch types is greater than a preset probability threshold; If so, determine the touch type with the higher probability as the current touch type; If not, determine the current touch type based on the pressure value.

[0009] In one optional implementation, the touch type discrimination model is trained using the following loss function.

[0010] in, ; In the formula, For accurate labeling, stylus type Gesture input type ; and These represent the probabilities that the current operation output by the touch type differentiation model belongs to the stylus type and the gesture input type, respectively. in, These are the weighting coefficients; ; In the formula, The normalized pressure value. The current preset pressure threshold; in, ; In the formula, The regularization coefficient is . This is the initial preset pressure threshold.

[0011] In one optional implementation, the current touch type is determined based on the pressure value, specifically including: Check if the pressure value exceeds the preset pressure threshold; If so, confirm that the current touch type is a stylus type; If not, confirm that the current touch type is gesture input.

[0012] In an optional implementation, the method further includes the following steps: After determining the current touch type, monitor subsequent operations to determine if there is a misjudgment; The recent misclassification rate can be calculated using the following formula.

[0013] in, Indicates the first Was this a misjudgment? If so, ,otherwise ; Indicates the first The exponentially decaying weight of the next generation It is the attenuation factor; The window length for calculating recent misclassification rates; The preset pressure threshold is corrected using the following formula. Current preset pressure threshold = previous preset pressure threshold - δ˙ recent misjudgment rate; Where δ is the learning rate.

[0014] Secondly, the technical solution of the present invention provides a system for H5 page responding to touch operations, comprising: The logic differentiation module is used to encapsulate the touch type differentiation logic of native applications into JS functions; The bridging layer building module is used to build the bridging layer, which exposes JS functions to the H5 page. This includes registering a class on the native application side, declaring a property and a method in the class. The property is used to store the operation parameters required to execute the JS function, and the method is used to call the JS function. The H5 page response module is used to retrieve operation parameters from the native application side and store them in the class's properties when the user performs an operation. The H5 page then calls a JS function through the bridge layer to obtain the current touch type based on the operation parameters and triggers the corresponding operation or interface feedback according to the current touch type.

[0015] Thirdly, the technical solution of the present invention provides a terminal, comprising: Memory, used to store the program that responds to touch operations on H5 pages; A processor, when executing a program for responding to touch operations on an H5 page, implements the steps of the method for responding to touch operations on an H5 page as described above.

[0016] Fourthly, the present invention provides a computer-readable storage medium storing a program for responding to touch operations on an H5 page, wherein when the program for responding to touch operations on an H5 page is executed by a processor, it implements the steps of the method for responding to touch operations on an H5 page as described in any of the above claims.

[0017] As can be seen from the above technical solutions, this application has the following advantages: First, the touch type differentiation logic of the native application is encapsulated into a JS function. Then, the JS function is exposed to the H5 page through a bridging layer. When the user performs an operation, the H5 page calls the JS function through the bridging layer to obtain the current touch type, and then triggers the corresponding operation or interface feedback based on the current touch type. This invention solves the problem that WebView components cannot correctly recognize stylus input by encapsulating the touch type differentiation logic of the native application into a JavaScript function and dynamically passing it to the H5 page through a bridging layer. Compared with the H5 page, which can only obtain the default "touch" type, this solution can accurately distinguish between gestures and stylus input, improving the accuracy and reliability of input judgment. Through the bridging layer design, low-latency data transmission between the native layer and the H5 page is achieved, and through the collaboration between the native and H5 layers, the allocation of system resources can be dynamically optimized. At the same time, the touch type differentiation logic is encapsulated into a standardized JavaScript interface, so developers do not need to reimplement complex touch judgment algorithms in the H5 page, reducing the cost of repetitive development. Attached Figure Description

[0018] To more clearly illustrate the technical solution of this application, the accompanying drawings used in the description will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a schematic flowchart illustrating a method for responding to touch operations on an H5 page, as provided in an embodiment of the present invention.

[0020] Figure 2 This is a schematic block diagram of a system structure for responding to touch operations on an H5 page, provided as an embodiment of the present invention.

[0021] Figure 3 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present invention. Detailed Implementation

[0022] To make the purpose, features, and advantages of this application more apparent and understandable, specific embodiments and accompanying drawings will be used to clearly and completely describe the technical solution protected by this application. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.

[0024] Figure 1 This is a flowchart illustrating a method for responding to touch operations on an H5 page, as provided in an embodiment of the present invention. Figure 1 The executing entity can be a system that responds to touch operations on an H5 page. The method for responding to touch operations on an H5 page provided in this embodiment of the invention is executed by a computer device; correspondingly, the system for responding to touch operations on an H5 page runs on the computer device. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.

[0025] like Figure 1 As shown, the method includes the following steps.

[0026] S1 encapsulates the native application's touch type differentiation logic into a JS function.

[0027] This step encapsulates the touch type differentiation logic implemented at the native application level into a JavaScript function (such as pointerType(event)) that can be called on the H5 page. By exposing the touch type determination capability through a standardized interface, the H5 page does not need to repeatedly develop the touch type determination logic. It can directly call the encapsulated JS function, reducing development costs and avoiding the limitations of the default H5 event model, thus improving the accuracy of touch type determination.

[0028] S2, construct a bridging layer to expose JS functions to H5 pages. This includes registering a class on the native application side, declaring a property and a method in the class. The property is used to store the operation parameters required to execute the JS function, and the method is used to call the JS function.

[0029] This step registers a bridge class on the native application side, declaring properties and methods. The properties store operation parameters for touch events (such as pressure values, timestamps, etc.), and the methods call encapsulated JS functions through the bridge layer, returning the execution results of the native logic to the H5 page. The bridge layer can be implemented using the operating system's WebView plugin mechanism, supporting bidirectional communication. The bridge layer achieves low-latency interaction between the native and H5 pages through lightweight data transfer (such as JSON serialization).

[0030] S3: When a user performs an operation, the native application obtains the operation parameters and stores them in the class's properties. The H5 page calls a JS function through the bridge layer, obtains the current touch type based on the operation parameters, and triggers the corresponding operation or interface feedback according to the current touch type.

[0031] This step enables the native application to capture touch events and extract operation parameters during user interactions, storing them in the properties of the bridge class. The H5 page calls a JS function through the bridge layer, obtains the current touch type (such as "stylus" or "gesture") based on the parameters, and triggers the corresponding front-end logic or UI feedback. The native layer captures and processes touch data in real time, while the H5 page synchronously obtains the results through the bridge layer, ensuring the immediacy of the interaction and avoiding the use of default touch types on the H5 page, thus improving the accuracy of the H5 page's touch response.

[0032] The method for H5 page responding to touch operations provided in this embodiment first encapsulates the touch type differentiation logic of the native application into a JS function. Then, it exposes the JS function to the H5 page through a bridging layer. When the user performs an operation, the H5 page calls the JS function through the bridging layer to obtain the current touch type, and then triggers the corresponding operation or interface feedback based on the current touch type. This method solves the problem that WebView components cannot correctly recognize stylus input by encapsulating the touch type differentiation logic of the native application into a JavaScript function and dynamically passing it to the H5 page through a bridging layer. Compared with the H5 page, which can only obtain the default "touch" type, this solution can accurately distinguish between gestures and stylus input, significantly improving the accuracy and reliability of input judgment. Through the bridging layer design, low-latency data transmission between the native layer and the H5 page is achieved, and through the collaboration between the native and H5 layers, system resource allocation can be dynamically optimized. At the same time, by encapsulating the touch type differentiation logic into a standardized JavaScript interface, developers do not need to reimplement complex touch judgment algorithms in the H5 page, reducing repetitive development costs.

[0033] Furthermore, as a refinement and extension of the specific implementation of the above embodiments, in order to fully illustrate the specific implementation process in this embodiment, another method for H5 page responding to touch operations is provided. This method can be applied to the HarmonyOS operating system and includes the following steps.

[0034] SS1 encapsulates the native application's touch type differentiation logic into a JS function.

[0035] In some alternative implementations, listeners for touch and stylus events are set up in the native application to monitor stylus-related events and gesture input-related events. For example, for stylus-related events, events such as stylusdown, stylusmove, and stylusup can be listened to. For gesture input, events such as touchstart, touchmove, and touchend can be listened to.

[0036] Extract necessary operational parameters from the above events, including coordinate sequence, pressure value, timestamp, touch area, and tilt angle. This information can be obtained through APIs provided by the operating system. Then, perform logical judgments based on the collected data.

[0037] In some alternative implementations, the logical judgment based on the collected data specifically includes the following steps.

[0038] Step 1: Calculate velocity and acceleration based on coordinate sequence and timestamp, using operation parameters, velocity, and acceleration as input data.

[0039] For adjacent coordinate points in the coordinate sequence, the velocity and acceleration are determined by combining the corresponding timestamps. The parameters during the operation (coordinate sequence, pressure value, timestamp, touch area, tilt angle), and the calculated velocity and acceleration are organized into input data.

[0040] Step 2: Divide the touch trajectory according to the preset time window and convert the input data of each time window into a feature vector.

[0041] Set the time window size according to actual needs, for example, set the time window to [size missing]. Starting from the start time of the touch trajectory, according to the time window Extract data sequentially. For example, if the first time window is from... arrive Then, all coordinate sequences, pressure values, timestamps, touch areas, tilt angles, speeds, and acceleration data within this time period will be extracted.

[0042] The input data within each time window is arranged and combined in a certain order to form a feature vector.

[0043] Step 3: Retrieve the pre-trained touch type discrimination model, input each feature vector into the touch type discrimination model to obtain the probability that the current operation belongs to two types of touch types; touch types include stylus type and gesture input type.

[0044] A pre-trained touch type discrimination model is introduced into the program. This model is trained based on a machine learning algorithm. The feature vectors obtained in step 2 are sequentially input into the touch type discrimination model. The model calculates based on the input feature vectors and outputs the probability that the current operation belongs to either the stylus type or the gesture input type.

[0045] In some alternative implementations, lightweight temporal models (such as LSTM or 1D-CNN) are used as touch type differentiation models, which are suitable for processing the temporal features of touch trajectories.

[0046] In some optional implementations, during the training of the touch type discrimination model, touch types (stylus / gesture) are automatically labeled using native layer logic (such as the `toolType` attribute) when preparing data, and users are allowed to manually correct misclassifications as a supervisory signal to enhance the dataset. First, an initial dataset (10,000+ samples) is collected. Then, it is divided into a training set (70%), a validation set (20%), and a test set (10%). Next, the model is trained and its parameters are tuned using the Adam optimizer and cross-entropy loss function. Finally, it is converted to TensorFlow Lite format (.tflite) and deployed to the HarmonyOS native application.

[0047] In practical applications, the TFLite model is loaded into the native layer, and inference is performed through the HarmonyOS AI framework interface (such as HiAI). The input is a real-time touch feature vector, and the output is the probability value of the stylus / gesture (e.g., [0.85, 0.15]).

[0048] In some alternative implementations, the cross-entropy loss function can effectively measure the difference between the model's predicted probability distribution and the true label. In this scenario, the stress threshold, as a dynamic parameter, also needs to be optimized. Therefore, adjusting the stress threshold is incorporated into the optimization process of the loss function.

[0049] The touch type discrimination model is trained using the following loss function.

[0050] The first term is the basic cross-entropy loss, which ensures the accuracy of the model's classification.

[0051]

[0052] In the formula, For accurate labeling, stylus type Gesture input type ; and These represent the probabilities that the current operation output by the touch type differentiation model belongs to the stylus type and the gesture input type, respectively.

[0053] The second term is the pressure threshold adjustment term, which forces the model prediction to be consistent with the pressure threshold through hinge loss.

[0054]

[0055] in, These are the weighting coefficients. The normalized pressure value. This represents the current training pressure threshold.

[0056] When the pressure value is higher than the threshold, the probability of encouraging the stylus is close to 1; when the pressure value is lower than the threshold, the probability of encouraging the stylus is close to 0, which can more directly constrain the consistency between the model's prediction and the pressure threshold.

[0057] The third term is the regularization term, which constrains the threshold. Around the initial value Adjustments should be made to avoid extreme deviations.

[0058]

[0059] In the formula, The regularization coefficient is . This is the initial training pressure threshold.

[0060] During training, initialize the threshold. Model weights are randomly initialized. Forward propagation is performed, inputting touch data (coordinates, pressure values, etc.), and the model outputs probabilities. and Calculate the total loss based on the true labels and stress values. Perform backpropagation and optimization, using the ADMA optimizer to adjust the model parameters and thresholds. Perform gradient descent optimization.

[0061] For example, the user taps the screen ( , Model output However, the pressure value is below the threshold. The adjustment takes effect; the second item... Increased loss forces the model to reduce its size. .

[0062] Step 4: Detect whether the probability of the larger of the various touch types is greater than the preset probability threshold.

[0063] From the two types of touch type probabilities obtained in step 3, obtain the probability of belonging to the stylus type and the probability of belonging to the gesture input type, compare the size of the two probabilities, and determine the larger probability value to compare with the preset probability threshold.

[0064] Step 5: If so, determine the touch type with the higher probability as the current touch type.

[0065] Step 6: If not, determine the current touch type based on the pressure value.

[0066] Step 6.1: Check whether the pressure value is greater than the preset pressure threshold.

[0067] Step 6.2: If yes, confirm that the current touch type is a stylus type.

[0068] Step 6.3: If not, determine that the current touch type is gesture input type.

[0069] The above steps, through multi-dimensional data analysis (such as speed, acceleration, and pressure values) and machine learning models, can more accurately distinguish between stylus input and gesture input, reducing misjudgments. Furthermore, when the probability values ​​for stylus input and gestures output by the machine learning model are ambiguous, a pressure threshold is used as a supplementary criterion to further improve the accuracy of the distinction.

[0070] In some alternative implementations, when the probability values ​​for stylus and gesture output by the machine learning model are ambiguous (e.g., probabilities close to 0.5), a pressure threshold serves as a supplementary criterion. For example, if the pressure value of a touch event is significantly higher than the threshold (e.g., 0.7), even if the model probability shows "gesture" (e.g., probability 0.55), it can still be corrected to "stylus". Conversely, if the pressure value is extremely low (e.g., 0.1), even if the model probability is biased towards "stylus" (e.g., 0.6), it can still be determined as "gesture". Styluses typically have pressure-sensing capabilities, while finger touches have lower pressure values. The pressure threshold directly reflects this physical difference and can verify the reasonableness of the model's predictions.

[0071] In some alternative implementations, the varying pressure applied by different users with the stylus is taken into account. For example, some users may lightly touch the screen to draw, while others may press harder, and the sensitivity of the touchscreen pressure sensors on different devices varies. For instance, the maximum pressure value for one tablet might be 1.0, while another might be 0.8. Furthermore, when the model's prediction confidence for a given input is low (e.g., probability 0.5-0.6), combining it with a preset pressure threshold can improve the robustness of classification. Therefore, dynamic thresholding can unify the user experience. The varying sensitivity of touchscreen pressure sensors on different devices (e.g., the maximum pressure value for one tablet might be 1.0, while another might be 0.8) further contributes to this. Additionally, when the model's prediction confidence for a given input is low (e.g., probability 0.5-0.6), combining it with a pressure threshold can improve the robustness of classification. Therefore, dynamically adjusting the pressure threshold to improve the accuracy of judgment specifically includes the following steps.

[0072] Step 1: After determining the current touch type, monitor subsequent operations to determine if there is a misjudgment.

[0073] Step 2: Calculate the recent misclassification rate using the following formula.

[0074] in, Indicates the first Was this a misjudgment? If so, ,otherwise ; Indicates the first The exponentially decaying weight of the next generation It is the attenuation factor; The window length is used to calculate the recent misclassification rate.

[0075] The calculation of recent misjudgment rates emphasizes the latest misjudgment events, enabling rapid response to changes in user behavior and avoiding statistical lag caused by fixed window lengths.

[0076] Step 3: Correct the preset pressure threshold using the following formula. Current preset pressure threshold = previous preset pressure threshold - δ˙ recent misjudgment rate; Where δ is the learning rate.

[0077] In some optional implementations, when the system determines a low confidence level (probability between 0.3 and 0.7), a dialog box pops up asking the user, "Is this a false positive?" The user clicks "Yes" or "No" to submit feedback. If the user explicitly responds "Yes," the current touch event is recorded as a false positive sample. In some optional implementations, subsequent user actions are monitored. If the user immediately performs an undo (e.g., erasing pen marks) after determining it to be a stylus, it is marked as a potential false positive. If the user repeatedly taps the same area and then switches modes, it is marked as a false positive.

[0078] For example, when a user lightly touches the screen to draw a thin line (pressure value 0.3), the model outputs a stylus input probability of 0.6 (due to the obvious pen stroke trajectory). Since the pressure value is below the threshold (0.5), the system identifies it as a gesture (false positive). The user manually switches to stylus mode, lowering the trigger threshold to 0.3, and subsequent similar operations are correctly recognized. For example, when a user writes forcefully (pressure value 0.7), the model outputs a gesture input probability of 0.55 (due to the rapid swiping trajectory resembling a gesture). Since the pressure value exceeds the threshold (0.5), it is corrected to stylus input.

[0079] In some alternative implementations, the logic for differentiating gestures from stylus input can be encapsulated into a series of easily invoked JavaScript functions. A pointerType(event) function can be defined that takes an event object as a parameter and returns either "gesture" or "stylus" based on the event content.

[0080] SS2 builds a bridging layer that exposes JavaScript functions to H5 pages. This includes registering a class on the native application side, declaring a property and a method in the class. The property stores the operation parameters required to execute the JavaScript function, and the method is used to call the JavaScript function.

[0081] In some alternative implementations, a class (such as TouchBridge) is defined in the native application to store touch parameters and call logic. The bridge class is then registered with the WebView, including initializing the WebView in the native application's UI components and injecting instances of the bridge class into the H5 page. The bridge layer can be implemented using the plugin mechanism provided by the operating system, allowing the H5 page to call native functions.

[0082] In SS3, when a user performs an action, the native application obtains the action parameters and stores them in the class's properties. The H5 page calls a JS function through the bridge layer, obtains the current touch type based on the action parameters, and triggers the corresponding operation or interface feedback according to the current touch type.

[0083] In some optional implementations, event listeners are pre-set to listen for stylus-related events and gesture input-related events; when the event listeners are triggered, operation parameters are extracted from the listened stylus-related events and gesture input-related events; and the operation parameters are stored in the class's properties.

[0084] In some alternative implementations, the H5 page extracts operation parameters from the class's properties; the operation parameters are then used as input to a JS function, which is executed to obtain the current touch type.

[0085] The H5 page calls a pre-packaged JS function through a bridge layer to obtain operation parameters: the operation parameters are extracted from the class properties and used as input to the JS function. The JS function is executed, and the current touch type is calculated and obtained based on the operation parameters. Touch types include stylus type and gesture input type. The specific logic process is as described in step SS1 and will not be repeated here. Based on the obtained current touch type, corresponding operations are triggered or interface feedback is displayed. For example, when stylus input is detected, more refined drawing tools may be provided; when gesture input is detected, zooming, swiping, and other operations may be performed.

[0086] This step accurately distinguishes between stylus and gesture input types, providing users with a more precise interactive experience. For example, in drawing applications, stylus input allows for more precise drawing, while gesture input enables zooming, panning, and other operations, avoiding accidental operations. Furthermore, H5 pages have excellent cross-platform compatibility; by combining with native applications through a bridging layer, a consistent interactive experience can be achieved across different devices and operating systems. Additionally, encapsulating the touch type detection logic into a JavaScript function facilitates H5 page calls, reducing repetitive work during development and improving development efficiency.

[0087] The foregoing has described in detail an embodiment of a method for responding to touch operations on an H5 page. Based on the method for responding to touch operations on an H5 page described in the above embodiment, this invention also provides a system for responding to touch operations on an H5 page corresponding to the method.

[0088] Figure 2 This is a schematic block diagram of a system structure for responding to touch operations on an H5 page, provided as an embodiment of the present invention. In this embodiment, the system 200 for responding to touch operations on an H5 page can be divided into multiple functional modules according to the functions it performs, such as... Figure 2 As shown. The functional modules may include: a differentiation logic encapsulation module 210, a bridging layer construction module 220, and an H5 page response module 230. The module referred to in this invention is a series of computer program segments that can be executed by at least one processor and perform a fixed function, and which are stored in memory.

[0089] The logic differentiation module 210 is used to encapsulate the touch type differentiation logic of the native application into a JS function.

[0090] The bridging layer construction module 220 is used to build the bridging layer, which exposes JS functions to the H5 page. This includes registering a class on the native application side, declaring a property and a method in the class. The property is used to store the operation parameters required to execute the JS function, and the method is used to call the JS function.

[0091] The H5 page response module 230 is used to obtain operation parameters from the native application side and store them in the class properties when the user performs an operation. The H5 page calls the JS function through the bridge layer, obtains the current touch type based on the operation parameters, and triggers the corresponding operation or interface feedback according to the current touch type.

[0092] The system for H5 page response touch operation in this embodiment is used to implement the aforementioned method for H5 page response touch operation. Therefore, the specific implementation of this system can be found in the embodiment section of the method for H5 page response touch operation mentioned above. Thus, the specific implementation can be referred to the description of the corresponding embodiments, and will not be elaborated here.

[0093] Furthermore, since the system for H5 page response touch operation in this embodiment is used to implement the aforementioned method for H5 page response touch operation, its function corresponds to the function of the above method, and will not be repeated here.

[0094] Figure 3 A schematic diagram of a terminal 300 provided in an embodiment of the present invention includes: a processor 310, a memory 320, and a communication unit 330. The processor 310, when implementing the program stored in the memory 320 for responding to touch operations on an H5 page, performs the following steps: The logic differentiation module is used to encapsulate the touch type differentiation logic of native applications into JS functions; The bridging layer building module is used to build the bridging layer, which exposes JS functions to the H5 page. This includes registering a class on the native application side, declaring a property and a method in the class. The property is used to store the operation parameters required to execute the JS function, and the method is used to call the JS function. The H5 page response module is used to retrieve operation parameters from the native application side and store them in the class's properties when the user performs an operation. The H5 page then calls a JS function through the bridge layer to obtain the current touch type based on the operation parameters and triggers the corresponding operation or interface feedback according to the current touch type.

[0095] The terminal 300 includes a processor 310, a memory 320, and a communication unit 330. These components communicate via one or more buses. Those skilled in the art will understand that the server structure shown in the figure does not constitute a limitation of the present invention. It can be a bus topology or a star topology, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0096] The memory 320 can be used to store the execution instructions of the processor 310. The memory 320 can be implemented by any type of volatile or non-volatile memory terminal or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. When the execution instructions in the memory 320 are executed by the processor 310, the terminal 300 is able to perform some or all of the steps in the above method embodiments.

[0097] The processor 310 serves as the control center of the storage terminal, connecting various parts of the electronic terminal via various interfaces and lines. It executes software programs and / or modules stored in the memory 320, and calls data stored in the memory to perform various functions of the electronic terminal and / or process data. The processor can be composed of integrated circuits (ICs), such as a single packaged IC or multiple packaged ICs with the same or different functions connected together. For example, the processor 310 may consist only of a central processing unit (CPU). In this embodiment of the invention, the CPU may have a single processing core or include multiple processing cores.

[0098] The communication unit 330 is used to establish a communication channel, enabling the storage terminal to communicate with other terminals. It can receive user data sent by other terminals or send user data to other terminals.

[0099] The present invention also provides a computer storage medium, which may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0100] The present invention also provides a computer storage medium, which may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0101] The computer storage medium stores a program that responds to touch operations on an H5 page. When the processor executes this program, the H5 page responds to touch operations by performing the following steps: The logic differentiation module is used to encapsulate the touch type differentiation logic of native applications into JS functions; The bridging layer building module is used to build the bridging layer, which exposes JS functions to the H5 page. This includes registering a class on the native application side, declaring a property and a method in the class. The property is used to store the operation parameters required to execute the JS function, and the method is used to call the JS function. The H5 page response module is used to retrieve operation parameters from the native application side and store them in the class's properties when the user performs an operation. The H5 page then calls a JS function through the bridge layer to obtain the current touch type based on the operation parameters and triggers the corresponding operation or interface feedback according to the current touch type.

[0102] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, mobile hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, or other media capable of storing program code. It includes several instructions to cause a computer terminal (which may be a personal computer, server, or a second terminal, network terminal, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0103] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0104] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0105] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0106] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for responding to touch operations on an H5 page, characterized in that, Includes the following steps: The logic for differentiating touch types in native applications is encapsulated into a JS function; Construct a bridging layer to expose JS functions to H5 pages. This includes registering a class on the native application side, declaring a property and a method in the class. The property is used to store the operation parameters required to execute the JS function, and the method is used to call the JS function. When a user performs an action, the native application obtains the action parameters and stores them in the class's properties. The H5 page calls a JS function through the bridge layer, obtains the current touch type based on the action parameters, and triggers the corresponding action or interface feedback based on the current touch type. The method also includes the following steps: After determining the current touch type, monitor subsequent operations to determine if there is a misjudgment; The recent misclassification rate can be calculated using the following formula. in, Indicates the first Was this a misjudgment? If so, ,otherwise ; Indicates the first The exponentially decaying weight of the next generation It is the attenuation factor; The window length for calculating recent misclassification rates; The preset pressure threshold is corrected using the following formula. Current preset pressure threshold = previous preset pressure threshold - δ˙ recent misjudgment rate; Where δ is the learning rate; Monitor subsequent user actions. If the user immediately cancels the action after it is determined to be a stylus, mark it as a potential misjudgment. If the user switches modes after multiple taps in the same area, mark it as a misjudgment. When a user performs an action, the native application retrieves the action parameters and stores them in the class's properties, specifically including: Pre-set event listeners to monitor stylus-related events and gesture input-related events; When the event listener is triggered, it extracts operation parameters from the listened stylus-related events and gesture input-related events. Store the operation parameters in the class's properties; The H5 page calls a JS function through a bridging layer to obtain the current touch type based on the operation parameters, specifically including: Extract operation parameters from class attributes; The operation parameters are used as input to a JS function, which is then executed to obtain the current touch type. Operational parameters include coordinate sequence, pressure value, timestamp, touch area, and tilt angle; The operation parameters are used as input to a JS function, which is then executed to obtain the current touch type, specifically including: Calculate velocity and acceleration based on coordinate sequence and timestamp, using operation parameters, velocity, and acceleration as input data; The touch trajectory is divided according to a preset time window, and the input data of each time window is converted into a feature vector; Retrieve a pre-trained touch type discrimination model, input each feature vector into the touch type discrimination model to obtain the probability that the current operation belongs to two touch types; touch types include stylus type and gesture input type; Detect whether the probability of a larger probability among various touch types is greater than a preset probability threshold; If so, determine the touch type with the higher probability as the current touch type; If not, the current touch type is determined based on the pressure value; The touch type discrimination model is trained using the following loss function. in, ; In the formula, For accurate labeling, stylus type Gesture input type ; and These represent the probabilities that the current operation output by the touch type differentiation model belongs to the stylus type and the gesture input type, respectively. in, These are the weighting coefficients; ; In the formula, The normalized pressure value. This represents the current training pressure threshold. in, ; In the formula, The regularization coefficient is . This is the initial training pressure threshold.

2. The method for responding to touch operations on an H5 page according to claim 1, characterized in that, The current touch type is determined based on the pressure value, specifically including: Check if the pressure value exceeds the preset pressure threshold; If so, confirm that the current touch type is a stylus type; If not, confirm that the current touch type is gesture input.

3. A system for H5 page responsive touch operation, applicable to the method for H5 page responsive touch operation as described in any one of claims 1-2, characterized in that, include: The logic differentiation module is used to encapsulate the touch type differentiation logic of native applications into JS functions; The bridging layer building module is used to build the bridging layer, which exposes JS functions to the H5 page. This includes registering a class on the native application side, declaring a property and a method in the class. The property is used to store the operation parameters required to execute the JS function, and the method is used to call the JS function. The H5 page response module is used to obtain the operation parameters on the native application side and store them in the class property when the user performs an operation. The H5 page calls the JS function through the bridge layer, obtains the current touch type based on the operation parameters, and triggers the corresponding operation or interface feedback according to the current touch type. It also includes: after determining the current touch type, monitoring subsequent operations to determine whether there is a misjudgment; The recent misclassification rate can be calculated using the following formula. in, Indicates the first Was this a misjudgment? If so, ,otherwise ; Indicates the first The exponentially decaying weight of the next generation It is the attenuation factor; The window length for calculating recent misclassification rates; The preset pressure threshold is corrected using the following formula. Current preset pressure threshold = previous preset pressure threshold - δ˙ recent misjudgment rate; Where δ is the learning rate; Monitor subsequent user actions. If the user immediately cancels the action after it is determined to be a stylus, it is marked as a potential misjudgment. If the user switches modes after multiple taps in the same area, it is marked as a misjudgment.

4. A terminal, characterized in that, include: Memory, used to store the program that responds to touch operations on H5 pages; A processor, when executing a program for responding to touch operations on an H5 page, implements the steps of the method for responding to touch operations on an H5 page as described in any one of claims 1 to 2.

5. A computer-readable storage medium, characterized in that, The readable storage medium stores a program for responding to touch operations on an H5 page. When the program for responding to touch operations on an H5 page is executed by a processor, it implements the steps of the method for responding to touch operations on an H5 page as described in any one of claims 1 to 2.

Citation Information

Patent Citations

  • Method and device for calling native application by HTML5 application

    CN110704131A

  • Hand touch and pen touch separation method and device in H5 webpage handwriting application and storage medium

    CN114115686A

  • Mobile terminal and controlling method thereof

    US9075471B2