Text interaction implementation method and device, equipment and storage medium
By setting up a proxy for the text view and writing callback methods, the problem of low development efficiency in the existing technology is solved by large amount of text interaction code, and efficient text interaction development is achieved.
Patent Information
- Application Number
- CN202411552780.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-03-14
AI Technical Summary
When implementing text interactions in the prior art, the code volume is large, resulting in a decrease in development efficiency.
By setting up a proxy for the text view and writing callback methods for the target text to the text view interaction event in the proxy, reduce the amount of code and improve development efficiency.
It realizes efficient development of text interaction, reduces the amount of code, and improves the work efficiency of developers.
Smart Images

Figure CN119625130A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent terminal technology, and in particular to a text interaction implementation method, device, equipment and storage medium. Background Art
[0002] In APP development, there is sometimes a scenario where there are some specific strings in a text, and the developer needs to ensure that the user can interact with these specific strings. For example, in the text "Regarding usage and failure situations, please review Manual and FAQ", the developer needs to ensure that the user clicks Manual to jump to the Manual interface, and clicks FAQ to jump to the FAQ interface. The amount of code used to achieve text interaction with current technology is relatively large, which reduces work efficiency to a certain extent.
[0003] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of this application is to provide a text interaction implementation method, device, equipment and storage medium, aiming to solve the technical problem that the current technology for implementing text interaction uses a large amount of code, which reduces work efficiency to a certain extent.
[0005] To achieve the above objectives, the present application proposes a text interaction implementation method, the method comprising:
[0006] Create a text view;
[0007] Fill the text view with target text;
[0008] An agent is set for the text view, and a callback method for the target text to the text view interaction event is written in the agent.
[0009] In one embodiment, the steps of setting a proxy for the text view and writing a callback method for the target text to the text view interaction event in the proxy include:
[0010] In response to the interaction request, the corresponding text view interaction event is processed through the callback method.
[0011] In one embodiment, the step of filling the text view with the target text includes:
[0012] Sets the text view to a non-editable state.
[0013] In one embodiment, the steps of setting a proxy for the text view and writing a callback method for the target text to the text view interaction event in the proxy include:
[0014] Calculating the position of a preset target character string in the target text and the length of the target character string;
[0015] Create a mutable rich text string object;
[0016] Setting the font attribute, font size, font color and link effect of the target string for the variable rich text string object;
[0017] The set variable rich text string object is assigned to the rich text editing properties of the text view, so that the target string in the text view displays the set font properties, font size, font color and link effect.
[0018] In one embodiment, the step of processing the corresponding text view interaction event by the callback method in response to the interaction request includes:
[0019] In response to the target string click request, the callback method is used to jump to the link corresponding to the target string.
[0020] In one embodiment, the step of processing the corresponding text view interaction event by the callback method in response to the interaction request includes:
[0021] In response to the target character string long press request, a corresponding long press interaction event is executed through the callback method.
[0022] In one embodiment, the step of processing the corresponding text view interaction event by the callback method in response to the interaction request includes:
[0023] In response to the target string drag request, a corresponding drag interaction event is executed through the callback method.
[0024] In addition, to achieve the above purpose, the present application also proposes a text interaction implementation device, the text interaction implementation device comprising:
[0025] View creation module, used to create text views;
[0026] A text filling module, used to fill the text view with target text;
[0027] The proxy setting module is used to set a proxy for the text view and to write a callback method for the target text to the text view interaction event in the proxy.
[0028] In addition, to achieve the above-mentioned purpose, the present application also proposes a text interaction implementation device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the text interaction implementation method described above.
[0029] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the text interaction implementation method described above are implemented.
[0030] One or more technical solutions proposed in this application have at least the following technical effects:
[0031] The present application can reduce the amount of code for implementing text interaction by setting a proxy for the text view and writing a callback method for the target text to the text view interaction event in the proxy, thereby improving the developer's work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0033] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0034] Figure 1 A flowchart of the first embodiment of the method for implementing text interaction of the present application is provided;
[0035] Figure 2 A flowchart of the second embodiment of the text interaction implementation method of the present application is provided;
[0036] Figure 3 A flowchart of the fourth embodiment of the text interaction implementation method of the present application is provided;
[0037] Figure 4 A code diagram for filling the text view with target text for this application;
[0038] Figure 5 A code diagram for setting a proxy for the text view in this application;
[0039] Figure 6 This is a schematic diagram of the module structure of the text interaction implementation device of the present application embodiment;
[0040] Figure 7 Schematic diagram of the device structure of the hardware operating environment involved in the text interaction implementation method in the embodiment of the present application.
[0041] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0042] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0043] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0044] The main solution of the embodiment of the present application is: create a text view; fill the text view with target text; set an agent for the text view, and write a callback method for the target text to the text view interaction event in the agent.
[0045] In this embodiment, for the convenience of description, the text interaction implementation system is used as the execution subject for explanation below.
[0046] Taking the text "Regarding usage and failure situations, please review Manual and FAQ" as an example, if the developer needs to implement clicking Manual to jump to the Manual interface and clicking FAQ to jump to the FAQ interface, most of the current solutions are to split this text into multiple parts. Taking the above text as an example, it can be split into "Regarding usage and failure situations, please review" is one part, "Manual" is one part, "and" is one part, and "FAQ" is one part, and then the first and third parts are displayed with Lab (label) text, the second and fourth parts are displayed with Button (button), and the Button text is assigned color and click events.
[0047] However, the above solution has four disadvantages:
[0048] First, you need to calculate the character length of each part, then set the length of Lab and Button, and then piece them together so that the whole will not be visible as a pieced-together effect.
[0049] Second, if a certain part of the text is too long and needs to be wrapped, it will greatly increase the difficulty of calculation for developers and make it difficult to determine the position of the button.
[0050] Third, if the APP is in multiple languages, the syntax and button positions in language A and language B may not be the same, so multiple sets of code logic need to be adapted according to the language.
[0051] Fourth, it will increase the amount of code and reduce the work efficiency of developers.
[0052] Therefore, the present application provides a solution. By setting a proxy for the text view and writing a callback method for the target text to the text view interaction event in the proxy, the present application can reduce the amount of code for implementing text interaction, thereby improving the developer's work efficiency.
[0053] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a text interaction realization device, etc., or an electronic system capable of realizing the above functions, a text interaction realization system, etc. The following takes the text interaction realization system as an example to illustrate this embodiment and the following embodiments.
[0054] Based on this, the present application embodiment provides a text interaction implementation method, referring to Figure 1 , Figure 1 A flowchart of the first embodiment of the text interaction implementation method of the present application is provided.
[0055] In this embodiment, the text interaction implementation method includes steps S10 to S20 and S80:
[0056] Step S10, creating a text view;
[0057] It should be noted that the present application can be applied to mobile terminal development, including Android terminal development and IOS terminal development, etc. In this embodiment, IOS terminal development is taken as an example.
[0058] Among them, the text view is represented as TextView in IOS development, and TextView is a common control developed on the IOS side.
[0059] Step S20, filling the text view with target text;
[0060] Reference Figure 4 , Figure 4 A code diagram for filling the text view with target text for this application.
[0061] For example, assuming the target text is “Regarding usage and failure situations, please review Manual and FAQ”, assign the value of TextView to “Regarding usage and failure situations, please review Manual and FAQ”.
[0062] Step S80, setting a proxy for the text view, and programming a callback method for the target text to the text view interaction event in the proxy.
[0063] It should be noted that in iOS development, Delegate is a design pattern that defines a one-to-one relationship between objects, in which one object (called "proxy object" or "delegate") acts as a communication intermediary or message forwarder for another object (called "proxy object" or "delegate"). This mechanism allows an object (proxy object) to pass messages or events to another object (proxy object) when specific events occur, instead of directly handling these events.
[0064] Take TextView as an example. TextView is a UI component that allows users to enter and edit text. In iOS, TextView provides a variety of callback mechanisms, which are implemented through the proxy mode. When the state of TextView changes (for example, start editing, end editing, text content changes, etc.), it notifies the outside world of these changes through its proxy object.
[0065] Among them, when the state of TextView changes, iOS will automatically call the corresponding proxy method. Through the proxy, additional behaviors can be added to it or specific events can be responded to without directly modifying the code of the proxied object. Therefore, the callback method corresponding to the target text can be implemented in the proxy.
[0066] This embodiment provides a method for implementing text interaction. By setting a proxy for the text view and writing a callback method for the target text to the text view interaction event in the proxy, the application can reduce the amount of code for implementing text interaction, thereby improving the developer's work efficiency.
[0067] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above introduction, and will not be repeated in the following. Figure 2 , Figure 2The flowchart of the second embodiment of the text interaction implementation method of the present application is provided. In step S80, after setting a proxy for the text view and writing a callback method for the target text to the text view interaction event in the proxy, the text interaction implementation method further includes step S90:
[0068] Step S90, in response to the interaction request, processing the corresponding text view interaction event through the callback method.
[0069] It should be noted that the user interacts with the text view (such as TextView) in the application, and this interaction may include clicking, double-clicking, long pressing, dragging, etc.
[0070] After the text view (the delegated object) recognizes these interaction events, it will call specific callback methods in its delegate object (usually a view controller or other object that follows the corresponding delegate protocol) according to the previously set delegate relationship. These callback methods are defined in the delegate protocol and are used to respond to different types of interaction events.
[0071] This embodiment processes the corresponding text view interaction events through the callback method, so that developers can add rich interactive behaviors and logical processing to the text view without directly modifying the code of the text view itself, reducing the amount of code for implementing text interaction, thereby improving the developer's work efficiency.
[0072] Based on the first embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above description, and will not be repeated hereafter. On this basis, after filling the target text into the text view in step S20, the text interaction implementation method further includes step S30:
[0073] Step S30, setting the text view to a non-editable state.
[0074] It should be noted that after filling in the target text, the developer hopes that the user can no longer edit the content in this text view. To achieve this, the developer needs to set the text view to a non-editable state.
[0075] Furthermore, this can be further emphasized to the user through other elements on the UI, such as labels, disabled states of buttons, etc. This can improve the user experience and prevent users from attempting editing operations that cannot be completed.
[0076] This embodiment sets the text view to a non-editable state so that the user can no longer edit the content in the text view, thereby achieving the effect required by the developer.
[0077] Based on the first embodiment of the present application, in the fourth embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above introduction, and will not be repeated in the following. Figure 3 , Figure 3 The flowchart of the fourth embodiment of the text interaction implementation method of the present application is provided. In step S80, before setting a proxy for the text view and writing a callback method for the target text to the text view interaction event in the proxy, the text interaction implementation method further includes steps S40 to S70:
[0078] Step S40, calculating the position of a preset target character string in the target text and the length of the target character string;
[0079] Assuming that the preset target strings are "Manual" and "FAQ" in "Regarding usage and failure situations, please review Manual and FAQ", you can use the rangeOfString method of NSString to get their starting point and string length.
[0080] Step S50, creating a variable rich text string object;
[0081] Among them, create an NSMutableAttributedString object, which can change the font attributes of TextView by assigning values.
[0082] Step S60, setting the font attributes, font size, font color and link effect of the target string for the variable rich text string object;
[0083] Among them, the font size of the target string is changed by setting NSFontAttributeName, the font color of the target string is changed by setting NSForegroundColorAttributeName, and the link effect of the target string is increased by setting NSLinkAttributeName.
[0084] Step S70, assigning the set variable rich text string object to the rich text editing properties of the text view, so that the target string in the text view displays the set font properties, font size, font color and link effect.
[0085] Among them, the variable rich text string object is assigned to the attributedText property of TextView.
[0086] It should be noted that attributedText is a rich text editor, which can change the color, font size, underline, etc. of certain text in TextView.
[0087] This embodiment provides a method for implementing text interaction. By setting a proxy for the text view and writing a callback method for the target text to the text view interaction event in the proxy, the application can reduce the amount of code for implementing text interaction, thereby improving the developer's work efficiency.
[0088] Based on the second embodiment of the present application, in the fifth embodiment of the present application, the same or similar contents as those in the second embodiment can be referred to the above description, and will not be repeated hereafter. On this basis, step S90, in response to the interaction request, processing the corresponding text view interaction event through the callback method also includes step S91:
[0089] Step S91, in response to a target string click request, jumping to a link corresponding to the target string through the callback method.
[0090] Reference Figure 5 , Figure 5 A schematic diagram of the code for setting the delegate for the text view for this application.
[0091] In the TextView delegate, you need to reimplement -(BOOL)textView:(UITextView*)textViewshouldInteractWithURL:(NSURL*)URL inRange:(NSRange)characterRangeinteraction:(UITextItemInteraction)interaction
[0092] This method will return three parameters. textView is the text view object, URL is the two assigned links, one is "Manual" and the other is "FAQ", characterRange is the position of the two links in the string (starting point and length), interaction is the type of interaction that is occurring (not used yet), and the return value of the method is a BOOL type (either Yes or No). If it is Yes, the interaction is allowed, otherwise it is not allowed.
[0093] This proxy method is mainly used to implement the interaction between text and some links. Because the NSLinkAttributeName attribute is set for "Manual" and "FAQ" in the previous step, the system will default them to a link address. When the user clicks on the location of these two strings, this callback will be automatically triggered. In this callback, you can intercept it (because these two are not a correct link address). If the URL obtained is "Manual", we will let it jump to the Manual interface, and if it is FAQ, we will jump to the FAQ interface.
[0094] By utilizing callback methods, developers can handle these interactions more efficiently. Once the link properties of the target string are set and the corresponding callback methods are implemented, developers no longer need to worry about the listening and parsing process of click events. When the user clicks the target string, the system automatically triggers the callback method and passes the relevant parameters (such as the URL and click location). Developers only need to write the jump logic in the callback method to easily implement text interaction.
[0095] This mechanism not only simplifies the development process, but also improves the readability and maintainability of the code. Since callback methods usually have clear naming and parameter lists, developers can more easily understand the functions and logic of the code. In addition, since callback methods are event-based, they are usually more flexible and extensible and can easily adapt to future changes in requirements.
[0096] Based on the second embodiment of the present application, in the sixth embodiment of the present application, the same or similar contents as those in the second embodiment can be referred to the above description, and will not be repeated hereafter. On this basis, on this basis, step S90, in response to the interaction request, processing the corresponding text view interaction event through the callback method also includes step S92:
[0097] Step S92, in response to the target character string long press request, executing a corresponding long press interaction event through the callback method.
[0098] Similarly, you can implement a custom long press gesture recognizer callback for TextView (or use the relevant proxy method) so that when the target string is subject to a long press request, the corresponding long press interaction event can be triggered and executed.
[0099] By utilizing callback methods, developers can handle these interactions more efficiently. Once the link properties of the target string are set and the corresponding callback methods are implemented, developers no longer need to worry about the listening and parsing process of click events. When the user long presses the target string, the system automatically triggers the callback method and passes the relevant parameters (such as the URL and click location). Developers only need to write the corresponding logic in the callback method to easily implement text interaction.
[0100] This mechanism not only simplifies the development process, but also improves the readability and maintainability of the code. Since callback methods usually have clear naming and parameter lists, developers can more easily understand the functions and logic of the code. In addition, since callback methods are event-based, they are usually more flexible and extensible and can easily adapt to future changes in requirements.
[0101] Based on the second embodiment of the present application, in the seventh embodiment of the present application, the same or similar contents as those in the second embodiment can be referred to the above description, and will not be repeated hereafter. On this basis, on this basis, step S90, in response to the interaction request, processing the corresponding text view interaction event through the callback method also includes step S93:
[0102] Step S93, in response to the target string drag request, executing a corresponding drag interaction event through the callback method.
[0103] Similarly, you can implement a custom drag gesture recognizer callback for TextView (or use the relevant proxy method) so that when the target string is requested to be dragged, the corresponding drag interaction event can be triggered and executed.
[0104] By utilizing callback methods, developers can handle these interactions more efficiently. Once the link properties of the target string are set and the corresponding callback methods are implemented, developers no longer need to worry about the listening and parsing process of click events. When the user drags the target string, the system automatically triggers the callback method and passes the relevant parameters (such as the URL and click location). Developers only need to write the corresponding logic in the callback method to easily implement text interaction.
[0105] This mechanism not only simplifies the development process, but also improves the readability and maintainability of the code. Since callback methods usually have clear naming and parameter lists, developers can more easily understand the functions and logic of the code. In addition, since callback methods are event-based, they are usually more flexible and extensible and can easily adapt to future changes in requirements.
[0106] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the text interaction implementation method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0107] This application also provides a text interaction implementation device, please refer to Figure 6 , the text interaction implementation device comprises:
[0108] A view creation module 10, used for creating a text view;
[0109] A text filling module 20, used to fill the text view with target text;
[0110] The proxy setting module 30 is used to set a proxy for the text view and to write a callback method for the target text to the text view interaction event in the proxy.
[0111] The text interaction implementation device provided by the present application adopts the text interaction implementation method in the above embodiment, which can solve the technical problem that the amount of code used in the current technology to implement text interaction is relatively large, which reduces the work efficiency to a certain extent. Compared with the prior art, the beneficial effects of the text interaction implementation device provided by the present application are the same as the beneficial effects of the text interaction implementation method provided by the above embodiment, and the other technical features in the text interaction implementation device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0112] The present application provides a text interaction implementation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the text interaction implementation method in the above-mentioned embodiment one.
[0113] Reference below Figure 7 , which shows a schematic diagram of the structure of a text interaction implementation device suitable for implementing the embodiments of the present application. The text interaction implementation device in the embodiments of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The text interaction implementation device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0114] like Figure 7As shown, the text interaction implementation device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the text interaction implementation device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the text interaction implementation device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a text interaction implementation device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0115] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0116] The text interaction implementation device provided by the present application adopts the text interaction implementation method in the above embodiment, which can solve the technical problem that the amount of code used in the current technology to implement text interaction is relatively large, which reduces the work efficiency to a certain extent. Compared with the prior art, the beneficial effects of the text interaction implementation device provided by the present application are the same as the beneficial effects of the text interaction implementation method provided by the above embodiment, and the other technical features in the text interaction implementation device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0117] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0118] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0119] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the text interaction implementation method in the above-mentioned embodiment.
[0120] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0121] The computer-readable storage medium mentioned above may be included in the text interaction implementation device; or may exist independently without being assembled into the text interaction implementation device.
[0122] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the text interaction implementation device, the text interaction implementation device is enabled to: create a text view; fill the target text into the text view; set an agent for the text view, and write a callback method for the target text to the text view interaction event in the agent.
[0123] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0124] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0125] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0126] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned text interaction implementation method, and can solve the technical problem that the amount of code used in the current technology to implement text interaction is relatively large, which reduces the work efficiency to a certain extent. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the text interaction implementation method provided by the above-mentioned embodiment, and will not be repeated here.
[0127] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A text interaction implementation method, characterized in that: The method comprises: Create a text view; Fill the text view with target text; An agent is set for the text view, and a callback method for the target text to the text view interaction event is written in the agent.
2. The method according to claim 1, characterized in that The steps of setting a proxy for the text view and writing a callback method for the target text to the text view interaction event in the proxy include: In response to the interaction request, the corresponding text view interaction event is processed through the callback method.
3. The method according to claim 1, characterized in that The step of filling the text view with the target text then includes: Sets the text view to a non-editable state.
4. The method according to claim 1, characterized in that The steps of setting a proxy for the text view and writing a callback method for the target text to the text view interaction event in the proxy include: Calculating the position of a preset target character string in the target text and the length of the target character string; Create a mutable rich text string object; Setting the font attribute, font size, font color and link effect of the target string for the variable rich text string object; The set variable rich text string object is assigned to the rich text editing properties of the text view, so that the target string in the text view displays the set font properties, font size, font color and link effect.
5. The method according to claim 2, characterized in that The step of processing the corresponding text view interaction event by the callback method in response to the interaction request includes: In response to the target string click request, the callback method is used to jump to the link corresponding to the target string.
6. The method according to claim 2, characterized in that The step of processing the corresponding text view interaction event by the callback method in response to the interaction request includes: In response to the target character string long press request, a corresponding long press interaction event is executed through the callback method.
7. The method according to claim 2, characterized in that The step of processing the corresponding text view interaction event by the callback method in response to the interaction request includes: In response to the target string drag request, a corresponding drag interaction event is executed through the callback method.
8. A text interaction implementation device, characterized in that: The device comprises: View creation module, used to create text views; A text filling module, used to fill the text view with target text; The proxy setting module is used to set a proxy for the text view and to write a callback method for the target text to the text view interaction event in the proxy.
9. A text interaction implementation device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the text interaction implementation method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the text interaction implementation method according to any one of claims 1 to 7 are implemented.