A kind of method and device for realizing scaling using middle button of mouse and idler wheel
Technical field
This application involves field of computer technology more particularly to a kind of methods for realizing scaling using middle button of mouse and idler wheel
And device.
Background technology
Current scale function is common in the touch screen with multi-touch function such as touch screen smart mobile phone, tablet computer
In digital equipment.When user is by two(Or more)When finger touches screen and slides in opposition, then it is equivalent to digital equipment
Instruction is reduced in input one, conversely, when user is by two(Or more)Finger touches screen and when sliding round about, then phase
When in digital equipment input an amplification instruction.Current scale function can be used for easily zooming in or out webpage, figure
Piece etc., facilitates user to browse.
Below by taking two touches as an example, illustrate the basic principle of current scale.2 points of user's touch are recorded first
Position M1 and M2 detect whether that slip event occurs, if so, determine using M1 as the terminal M3 of the first slip event of starting point,
And using M2 as the terminal M4 of the second slip event of starting point, if the distance between M3 and M4 K1 are less than the distance between M1 and M2
K2, then carry out diminution processing to browsing content, and reduced scale is proportional to the difference between the distance K1 and K2;If distance K1
More than distance K2, then processing is amplified to browsing content, the ratio of amplification is proportional to the difference between the distance K1 and K2.
As can be seen that the realization of existing this current scale function depends on touch screen.Do not have for other
The digital equipment of touch screen, then cannot achieve current scale.It is touched for example, although current many set-top box devices have identification multiple spot
Touch the ability of event, but the video screen that is connected of set-top box does not have the function of touch screen usually, mouse can only be used to machine
Top box is controlled, and realizes that fairly simple operation as clicked, pulls, sliding etc.;In browsing map, webpage, when picture, can not
Realize that the scaling of content, user experience are bad.
Invention content
This application provides a kind of method and devices for realizing scaling using middle button of mouse and idler wheel, can only pass through mouse
Zoom function is conveniently realized, user experience is enhanced.
A kind of method for realizing scaling using middle button of mouse and idler wheel provided by the embodiments of the present application, including:
A, it detects that middle button of mouse is pressed, judges whether mouse roller rolls, if so, executing step B, otherwise exit this stream
Journey;
B, two coordinates P1 and P2 of record on the straight line L by mouse pointer changing coordinates P0, the P1 and P2 distinguish
Positioned at the both sides of P0;
C, judge the rotating direction of mouse roller, if being rolled to first direction, execute step D, if second direction rolls, hold
Row step E;The first direction and the opposite each other direction of second direction;
D, it detects that middle button of mouse lifts, generates two slip events S1 and S2 by starting point of coordinate P1 and P2 respectively, and
Processing is amplified to browsing content according to slip event S1 and S2 triggering, and terminates this flow;Wherein slip event S1 is with P1
For starting point, glide direction deviates from P0 along straight line L, and for slip event S2 using P2 as starting point, glide direction deviates from P0 along straight line L;
E, it detects that middle button of mouse lifts, generates two slip events S3 and S4 by starting point of coordinate P1 and P2 respectively, and
Diminution processing is carried out to browsing content according to slip event S3 and S4 triggering, and terminates this flow;Wherein slip event S3 is with P1
For starting point, glide direction is along straight line L towards P0, and slip event S4 is using P2 as starting point, and glide direction is along straight line L towards P0.
Preferably, in the step D, the lattice number N1 that mouse roller is rolled to first direction, slip event S1 and S2 are determined
Sliding distance be proportional to N1;The magnification ratio for being amplified processing to browsing content according to slip event S1 and S2 triggering
It is proportional to the sliding distance of slip event S1 and S2.
Preferably, in the step E, the lattice number N2 that mouse roller is rolled to second direction, slip event S3 and S4 are determined
Sliding distance be proportional to N2;The diminution ratio for browsing content reduce processing according to slip event S3 and S4 triggering
It is proportional to the sliding distance of slip event S3 and S4.
Preferably,
The straight line L and the angle in screen level direction are 0 degree, 45 degree, 90 degree.
Preferably, component is m × N1 to the sliding distance of the slip event S1 in the horizontal direction, in vertical direction component
For-n × N1, component is-m × N1 to the sliding distance of slip event S2 in the horizontal direction, is n × N1 in vertical direction component,
Middle m is the absolute value that mouse roller rolls the sliding distance of slip event generated when 1 lattice component in the horizontal direction, and n is mouse
Idler wheel rolls absolute value of the sliding distance in vertical direction component of the slip event generated when 1 lattice.
Preferably, component is-m × N2 to the sliding distance of the slip event S3 in the horizontal direction, in vertical direction component
For n × N2, component is m × N2 to the sliding distance of slip event S4 in the horizontal direction, is-n × N2 in vertical direction component, wherein
M is the sliding distance absolute value in the horizontal direction that mouse roller rolls the slip event generated when 1 lattice, and n rolls for mouse roller
Absolute value of the sliding distance of the slip event generated when dynamic 1 lattice in vertical direction component.
The embodiment of the present application also provides a kind of device for realizing scaling using middle button of mouse and idler wheel, including:
First judging unit judges whether mouse roller rolls after detecting that middle button of mouse is pressed, if so, enabled
Scaling processing module;
Scaling processing module, for zooming in or out processing to browsing content, including:
Initial coordinate recording unit, for recording two coordinate P1 on the straight line L by mouse pointer changing coordinates P0
And P2, the P1 and P2 are located at the both sides of P0;
Second judgment unit, the rotating direction for judging mouse roller enable enhanced processing list if first direction
Member enables to reduce processing unit if second direction;The first direction and the opposite each other direction of second direction;
Magnification processing, for after detecting that middle button of mouse lifts, generating two by starting point of coordinate P1 and P2 respectively
A slip event S1 and S2, and processing is amplified to browsing content according to slip event S1 and S2 triggering;Wherein slip event
For S1 using P1 as starting point, glide direction deviates from P0 along straight line L, and slip event S2 using P2 as starting point, along straight line L carry on the back by glide direction
From P0;
Processing unit is reduced, for after detecting that middle button of mouse lifts, generating two by starting point of coordinate P1 and P2 respectively
A slip event S3 and S4, and diminution processing is carried out to browsing content according to slip event S3 and S4 triggering;Wherein slip event
S3 is using P1 as starting point, and glide direction is along straight line L towards P0, and slip event S4 is using P2 as starting point, and glide direction is along straight line L courts
To P0.
Preferably, the magnification processing determines lattice the number N1, slip event S1 that mouse roller is rolled to first direction
It is proportional to N1 with the sliding distance of S2;The amplification for being amplified processing to browsing content according to slip event S1 and S2 triggering
Ratio is proportional to the sliding distance of slip event S1 and S2.
Preferably, the diminution processing unit determines lattice number N2, slip event S3 that mouse roller is rolled to second direction
It is proportional to N2 with the sliding distance of S4;The diminution for browsing content reduce processing according to slip event S3 and S4 triggering
Ratio is proportional to the sliding distance of slip event S3 and S4.
Preferably,
The initial coordinate recording unit includes:
Straight line determination subelement, for determining that with the angle in screen level direction be 0 degree, 45 degree, 90 degree of straight line L..
Preferably, the magnification processing includes:
First sliding distance handles subelement, for determining that component is m to the sliding distance of slip event S1 in the horizontal direction
× N1 is-n × N1 in vertical direction component, and component is-m × N1 to the sliding distance of slip event S2 in the horizontal direction, vertical
Durection component is n × N1, and wherein m is that mouse roller rolls the sliding distance of the slip event generated when 1 lattice horizontal or vertical
The absolute value in direction, n are that mouse roller rolls the sliding distance of the slip event generated when 1 lattice in the absolute of vertical direction component
Value.
Preferably, the diminution processing unit includes:
Second sliding distance handles subelement, for determining that component is-m to the sliding distance of slip event S3 in the horizontal direction
× N2 is n × N2 in vertical direction component, and component is m × N2 to the sliding distance of slip event S4 in the horizontal direction, in vertical side
It is-n × N2 to component, wherein m is that mouse roller rolls the sliding distance of the slip event generated when 1 lattice in x-axis or y-axis direction
Absolute value, n be mouse roller roll the sliding distance of slip event that is generated when 1 lattice vertical direction component absolute value.
As can be seen from the above technical solutions, two slidings can be simulated by using the combination of middle button of mouse and idler wheel
Event can simulate the effect of two touches, to realize current scale, pass through mouse side in the equipment for not having touch screen
Just it realizes zoom function, enhances user experience.
Description of the drawings
Fig. 1 is that this application provides a kind of method flow schematic diagrams for realizing scaling using middle button of mouse and idler wheel;
Fig. 2 is that middle button of mouse is pressed in the embodiment of the present application, and when idler wheel starts to roll generates and presses the signal of event
Figure;
Fig. 3 is the schematic diagram for the coordinate that mouse roller records during rolling backward in the embodiment of the present application;
Fig. 4 is the device block diagram provided by the embodiments of the present application that scaling is realized using middle button of mouse and idler wheel.
Specific implementation mode
This application provides a kind of methods for realizing scaling using middle button of mouse and idler wheel, as shown in Figure 1, including following step
Suddenly:
Step 101:It detects that middle button of mouse is pressed, judges whether mouse roller rolls, if so, executing step 102, otherwise
Exit this flow;
Step 102:Two coordinate P1 and P2 of record on the straight line L by mouse pointer changing coordinates P0, the P1 and
P2 is located at the both sides of P0;
Step 103:Judge the rotating direction of mouse roller, if being rolled to first direction, step 104 is executed, if second party
To rolling, step 105 is executed;The first direction and the opposite each other direction of second direction, for example, first direction is forward,
Second direction is backward;
Step 104:Detect that middle button of mouse lifts, respectively using coordinate P1 and P2 as starting point generate two slip event S1 and
S2, and processing is amplified to browsing content according to slip event S1 and S2(Simulate two touch zoom operations), and terminate this
Flow;For wherein slip event S1 using P1 as starting point, glide direction deviates from P0 along straight line L, and slip event S2 is sliding using P2 as starting point
Dynamic direction deviates from P0 along straight line L;
Step 105:Detect that middle button of mouse lifts, respectively using coordinate P1 and P2 as starting point generate two slip event S3 and
S4, and diminution processing is carried out to browsing content according to slip event S3 and S4(Simulate two touch zoom operations), and terminate this
Flow;Wherein slip event S3 is using P1 as starting point, and for glide direction along straight line L towards P0, slip event S4 is sliding using P2 as starting point
Dynamic direction is along straight line L towards P0.
As can be seen that this method can simulate two slip events by using the combination of middle button of mouse and idler wheel, it can
To simulate the effect of two touches, to realize current scale.
In the step 104, the lattice number N1 that mouse roller is rolled to first direction, the sliding of slip event S1 and S2 are determined
Distance is proportional to N1;The magnification ratio for being amplified processing to browsing content according to slip event S1 and S2 triggering is proportional to
The sliding distance of slip event S1 and S2.
It is similar, in the step 105, determine lattice number N2, slip event S3 that mouse roller is rolled to second direction and
The sliding distance of S4 is proportional to N2;The drawdown ratio for browsing content reduce processing according to slip event S3 and S4 triggering
Example is proportional to the sliding distance of slip event S3 and S4.The sliding distance of the slip event S1 in the horizontal direction component be m ×
N1 is-n × N1 in vertical direction component, and component is-m × N1 to the sliding distance of slip event S2 in the horizontal direction, in vertical side
It is n × N1 to component;Component is-m × N2 to the sliding distance of the slip event S3 in the horizontal direction, is in vertical direction component
Component is m × N2 to the sliding distance of n × N2, slip event S4 in the horizontal direction, is-n × N2, wherein m in vertical direction component
The sliding distance absolute value in the horizontal direction of the slip event generated when rolling 1 lattice for mouse roller, n roll for mouse roller
Absolute value of the sliding distance of the slip event generated when 1 lattice in vertical direction component.
Straight line L by mouse changing coordinates P0 can be any direction, such as can be the vertical direction along screen,
Horizontal direction, the i.e. horizontal sextant angle of straight line L and screen are 90 degree, 0 degree.Determine coordinate P1, P2 mode can also there are many, only
Want P1 and P2 respectively in the both sides P0, relatively conventional mode is that P1 and P2 distances P0 is fixed value.
Preferably, straight line L and the angle of horizontal direction are 45 degree, the sliding distance of the slip event S1 is in x-axis direction
(Horizontal direction)It is-m*N1 in y-axis direction for m*N1, the sliding distance of slip event S2 is-m*N1 in x-axis direction, in y-axis
Direction(Vertical direction)It is that mouse roller rolls the sliding distance of the slip event generated when 1 lattice in x-axis or y for m*N1, wherein m
The absolute value of axis direction.
The sliding distance of the slip event S3 is-m*N2 in x-axis direction, is m*N2 in y-axis direction, slip event S4's
Sliding distance is m*N2 in x-axis direction, is-m*N2 in y-axis direction, wherein m is that mouse roller rolls the sliding thing generated when 1 lattice
Absolute value of the sliding distance of part in x-axis or y-axis direction.
To keep the technical principle, feature and technique effect of technical scheme clearer, below in conjunction with specific reality
Example is applied technical scheme is described in detail.
Application embodiment provides a kind of method for realizing idler wheel scaling using middle button of mouse and idler wheel.As illustrated in fig. 2, it is assumed that
Mouse coordinates are P0 at this time(640,360)(Unit is pixel).When middle button of mouse is pressed, and idler wheel starts to roll, meeting exists
P1 (740,260) and P2(540,460)It generates two and presses event, the two press the coordinate line L and horizontal direction of event
Angle be 45 degree.As shown in figure 3, when mouse roller rolls a lattice backward, two coordinates P3 and P4 can be recorded.Wherein P3 and P1
In the directions x, distance is -5 pixels, and distance is 5 pixels on the directions y;P4 and P2 in the x direction at a distance from be 5 pixels, the side y
Upward distance is -5 pixels.Hereafter mouse roller often slides a lattice, all can be based on the point that the last time generates, according to upper
One step process records two coordinates, such as P5, P6.After middle button of mouse unclamps, generated with the coordinate of two coordinates finally recorded
Two are lifted event, and one positioned at the same sides P0 presses event and one is lifted event and constitutes a complete sliding thing
Part, as soon as therefore the both sides P0 respectively constitute a slip event, so far one diminution gesture complete.
The gesture of amplification is similar, only P3, and P4 is generated in P1, the outside of P2.It can also will amplify and reduce gesture
It is used in mixed way, as long as remaining that middle button of mouse is in down state.
The embodiment of the present application also provides a kind of devices for realizing scaling using middle button of mouse and idler wheel, as shown in figure 4, packet
It includes:
First judging unit 401 judges whether mouse roller rolls after detecting that middle button of mouse is pressed, if so, making
It can scaling processing module 402;
Scaling processing module 402, for zooming in or out processing to browsing content, including:
Initial coordinate recording unit 403, for recording two coordinates on the straight line L by mouse pointer changing coordinates P0
P1 and P2, the P1 and P2 are located at the both sides of P0;
Second judgment unit 404, the rotating direction for judging mouse roller enable enhanced processing if first direction
Unit 405 enables to reduce processing unit 406 if second direction;The first direction and the opposite each other side of second direction
To;
Magnification processing 405, for after detecting that middle button of mouse lifts, being generated respectively by starting point of coordinate P1 and P2
Two slip events S1 and S2, and processing is amplified to browsing content according to slip event S1 and S2 triggering;Wherein slide thing
Part S1 is using P1 as starting point, and glide direction deviates from P0 along straight line L, and slip event S2 is using P2 as starting point, and glide direction is along straight line L
Away from P0;
Processing unit 406 is reduced, for after detecting that middle button of mouse lifts, being generated respectively by starting point of coordinate P1 and P2
Two slip events S3 and S4, and diminution processing is carried out to browsing content according to slip event S3 and S4 triggering;Wherein slide thing
Part S3 is using P1 as starting point, and glide direction is along straight line L towards P0, and slip event S4 is using P2 as starting point, and glide direction is along straight line L
Towards P0.
Preferably, the magnification processing 405 determines the lattice number N1 that mouse roller is rolled to first direction, slip event
The sliding distance of S1 and S2 is proportional to N1;It is described processing is amplified to browsing content according to slip event S1 and S2 triggering to put
Large scale is proportional to the sliding distance of slip event S1 and S2.
Preferably, the processing unit 406 that reduces determines the lattice number N2 that mouse roller is rolled to second direction, slip event
The sliding distance of S3 and S4 is proportional to N2;The contracting for browsing content reduce processing according to slip event S3 and S4 triggering
Small scale is proportional to the sliding distance of slip event S3 and S4.
Preferably, the first direction that the second judgment unit is judged is forward, second direction is backward.
Preferably, the initial coordinate recording unit includes:
Straight line determination subelement, for determining that with the angle in screen level direction be 0 degree, 45 degree, 90 degree of straight line L.
Preferably, the magnification processing includes:
First sliding distance handles subelement, for determining that component is m to the sliding distance of slip event S1 in the horizontal direction
× N1 is-n × N1 in vertical direction component, and component is-m × N1 to the sliding distance of slip event S2 in the horizontal direction, vertical
Durection component is n × N1, and wherein m is that mouse roller rolls the sliding distance of the slip event generated when 1 lattice horizontal or vertical
The absolute value in direction, n are that mouse roller rolls the sliding distance of the slip event generated when 1 lattice in the absolute of vertical direction component
Value.
Preferably, the diminution processing unit includes:
Second sliding distance handles subelement, for determining that component is-m to the sliding distance of slip event S3 in the horizontal direction
× N2 is n × N2 in vertical direction component, and component is m × N2 to the sliding distance of slip event S4 in the horizontal direction, in vertical side
It is-n × N2 to component, wherein m is that mouse roller rolls the sliding distance of the slip event generated when 1 lattice in x-axis or y-axis direction
Absolute value, n be mouse roller roll the sliding distance of slip event that is generated when 1 lattice vertical direction component absolute value.
Through the above description of the embodiments, those skilled in the art can be understood that the present invention can be by
Software adds the mode of required hardware platform to realize, naturally it is also possible to all implemented by hardware, but in many cases before
Person is more preferably embodiment.Based on this understanding, technical scheme of the present invention contributes to background technology whole or
Person part can be expressed in the form of software products, which can be stored in a storage medium, such as
ROM/RAM, magnetic disc, CD etc., including some instructions are used so that a computer equipment(Can be personal computer, service
Device or the network equipment etc.)Execute the method described in certain parts of each embodiment of the present invention or embodiment.
The foregoing is merely the preferred embodiments of the application, not to limit the protection domain of the application, it is all
Within the spirit and principle of technical scheme, any modification, equivalent substitution, improvement and etc. done should be included in this Shen
Within the scope of please protecting.