Change Mouse/ Cursor appearance in ginput
37 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Simple Question:
is it possible to Change the Cursor appearance in ginput ?
Explanation:
If you use the ginput command, you will get a Crosshair as Cursor.Is it possible to get something like a grapping hand or ..... If you open a new figure and look into the menu bar, u will find a Pointer,a magnifier and a hand. Can i get these Objects for ginput ?
0 commentaires
Réponses (3)
Adam
le 25 Sep 2014
Modifié(e) : Adam
le 25 Sep 2014
As far as I know you cannot set pointer type for ginput.
might be useful to you. It is something we (the team I work in) downloaded a while back for use in place of ginput for pretty much the same reason as you. It allows you to specify pointer type.
It is a horribly named function but it does a good job.
You can use any pointer type that you can set on a fig. These can be found by just typing:
set( gcf, 'pointer' )
on any figure you have. Any option in there should be usable so far as I know and looking at the code as that is the property it sets with the pointer string you pass in.
3 commentaires
Adam
le 25 Sep 2014
Modifié(e) : Adam
le 25 Sep 2014
[xVal, yVal, button] = myginput( 1, 'crosshair' );
is how I used it in one of our programs so it appears to git the same syntax. The help at the top of the file also confirms syntax is identical to ginput except for the final extra argument.
It is a fileexchange download so you can simply edit the file and rename it if you want, taking note of any license requirements it has. In this case there appears to be no license file with it at all so you can do whatever you want with it for your own usage.
Obviously you could also simply create a wrapper function with a name you prefer as e.g.
function [x,y,button] = myBetterName( args )
[x,y,button] = myginput( args );
where 'args' would obviously be replaced by whatever inputs it expects. Then you can just call your own named wrapper function.
Sean de Wolski
le 25 Sep 2014
@Adam: Being covered by the BSD license explicitly allows you to modify and redistribute.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Sean de Wolski
le 25 Sep 2014
What are you trying to do?
I typically avoid ginput and would recommend using an impoint (Image Processing Tbx req'd) instead.
Johannes Korsawe
le 9 Juin 2023
Modifié(e) : Johannes Korsawe
le 9 Juin 2023
This can be done very easily:
- Use a local copy of Mathworks' original function ginput.m which has precedence in your Matlab path.
- Adapt this copy to take two arguments: "Number of ginput points" and "pointersymbol". Make sure that the pointersymbol is set to [] if nargin==1.
- Add pointersymbol as a second argument to the call and definition of the local funtion setupFcn inside ginput.
- use the following code iside the local function setupFcn before the setup of the "ginput"-pointer:
try
%Setup custom pointer
set(gcf, 'Pointer', pointerSymbol);
%Define the following entities, s.t. the restoreFcn has something to delete
initialState.CrossHair = createCrossHair(fig);
initialState.MouseListener = createCrossHair(fig);
catch
%Setup empty pointer
...
end
Done. You can call the by ginput(5) to show the Mathworks' intended pointer behavior or use e.g. ginput(5, 'crosshair') to prescribe a custom pointer as a a figure property.
0 commentaires
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!