Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
setptr

Subject: setptr

From: Mohammad salehizadeh

Date: 29 Jan, 2008 21:58:01

Message: 1 of 4

I want to know what is function of hittest and setptr in
the following instruction?
 



%%%%%%%%%%%%%%
% localHover %
%%%%%%%%%%%%%%
function localHover(eventSrc,eventData)
 %---WindowButtonMotionFcn
  obj = hittest(eventSrc);
  switch lower(get(obj,'tag'))
  case 'slider'
     setptr(eventSrc,'hand');
  otherwise
     setptr(eventSrc,'arrow');
  end

Subject: setptr

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 29 Jan, 2008 22:12:03

Message: 2 of 4

In article <fno7h9$3mb$1@fred.mathworks.com>,
Mohammad salehizadeh <en66salehi.mohammad@example.com> wrote:
>I want to know what is function of hittest and setptr in
>the following instruction?

>%%%%%%%%%%%%%%
>% localHover %
>%%%%%%%%%%%%%%
>function localHover(eventSrc,eventData)
> %---WindowButtonMotionFcn
> obj = hittest(eventSrc);
> switch lower(get(obj,'tag'))
> case 'slider'
> setptr(eventSrc,'hand');
> otherwise
> setptr(eventSrc,'arrow');
> end

Both hittest() and setptr() appear to be local functions,
or perhaps defined in some Matlab toolbox that I do not have.

My deduction for setptr would be:

function setptr(eventSrc,shape)
  set(eventSrc, 'Pointer', shape)
end

That is, set the figure pointer to be the given shape.


hittest:

The source event that you get for the localHover function is the
figure, not an individual object. I believe hittest() applied to the
figure must somehow determine which object within the figure is
being pointed to, and returns the handle of that object.

But checking the tag of an object against the string 'slider' would
not be the most robust way to detect a uicontrol of type slider,
as tags can be defined by the user. *Possibly* the object returned
is even lower level than uicontrol(), if the localHover() function
is intended to switch to the hand pointer only when you are pointing
to some sub-parts of a slider uicontrol.
--
This is a Usenet signature block. Please do not quote it when replying
to one of my postings.
http://en.wikipedia.org/wiki/Signature_block

Subject: setptr

From: Malcolm Lidierth

Date: 30 Jan, 2008 17:50:20

Message: 3 of 4

setptr is a standard ML function - type help setptr

hittest is undocumented. It returns the handle of the
object under the CurrentPoint in the figure. If
WindowButtonMotionFcn or WindowButtonUpFcn are inactive,
that should correspond to gco, the last object clicked on.
Otherwise it will be the object underneath the presently
displayed cursor position. See the doc for figure
properties (CurrentPoint).

Subject: setptr

From: Yair Altman

Date: 30 Jan, 2008 18:15:06

Message: 4 of 4

"Malcolm Lidierth" <ku.ca.lck@htreidil.mloclam> wrote in
message <fnqdcs$qu5$1@fred.mathworks.com>...

> setptr is a standard ML function - type help setptr


I beg to disagree: setptr is an internal Matlab function
that is unsupported and only semi-documented: it has a help
page but no doc page and no online help. This is probably
due to an error on the part of MathWorks programmers, who
forgot to un-help this function using the standard "This is
undocumented, unsupported and will change in future versions
yada yada" message. There are a few other similar
semi-documented functions lurking around (it's so much fun
finding them!). The criteria for whether a function is
supported or not seems to be the availability of a doc page,
not a help page.

Specifically regarding setptr - this is a very useful
function that has been around for many years. It's a pity
it's still officially unsupported (I haven't checked whether
this has changed in R2008a).

Yair Altman
http://ymasoftware.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us