How do I restrict mouse cursor movement area?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I restrict mouse cursor movement area?

John Trinder
Hi all,

     I want to restrict the mouse cursor movements to a specific
sub-view. I know it can be done in C++ but I can't find any methods
belonging to class Cursor or it's super-classes.
     Can anybody supply me with a quick reply here?
     Thanks all,
     Regards, John Trinder


Reply | Threaded
Open this post in threaded view
|

Re: How do I restrict mouse cursor movement area?

Bruno Brasesco
>      I want to restrict the mouse cursor movements to a specific
> sub-view. I know it can be done in C++ but I can't find any methods
> belonging to class Cursor or it's super-classes.
>      Can anybody supply me with a quick reply here?

I do not know what do you want to do..., but you can look

#onMouseMoved: aMouseEvent

You can implement #onMouseMoved: in your specific view (under View
hierarchy).

Hope this help.

Regards Bruno


Reply | Threaded
Open this post in threaded view
|

Re: How do I restrict mouse cursor movement area?

John Trinder
Thanks for your response.
Basically, what I want to do is to implement the following C++
function in Dolphin:

BOOL ClipCursor(

    CONST RECT *lpRect // pointer to structure with rectangle  
   );

I think I can achieve it by examining dolphin code, but it seems
somewhat complex, perhaps someone can show me the way :)
Also, after usage the cursor movements need to be set to the screen
area. This is done in the above by sending NULL as the parameter. How
does one implement NULL in dolphin?

Regards, John Trinder


Reply | Threaded
Open this post in threaded view
|

Re: How do I restrict mouse cursor movement area?

Ian Bartholomew-18
John,

> I think I can achieve it by examining dolphin code, but it seems
> somewhat complex, perhaps someone can show me the way :)
> Also, after usage the cursor movements need to be set to the screen
> area. This is done in the above by sending NULL as the parameter. How
> does one implement NULL in dolphin?

I didn't realise there was a single api method for that - you live and learn
:-)

Add the following method to the UserLibrary class

clipCursor: lprc
    <stdcall: bool ClipCursor RECT*>
    ^self invalidCall

Copy the following to a workspace and evaluate it. This prevents the cursor
entering a 100 pixel wide margin around the desktop.

rect := (View desktop rectangle) insetBy:100.
UserLibrary default clipCursor: (RECT fromRectangle: rect)

To remove the restriction evaluate

UserLibrary default clipCursor: nil

To do the same to a view you have to find the #screenRectangle of the view
and use that as the parameter.  In a workspace demo this is a bit more
difficult as you need to find the workspace first but this should give you
the idea.

me := SmalltalkWorkspaceDocument allInstances first.
UserLibrary default
    clipCursor: (RECT fromRectangle: me view screenRectangle)

Ian


Reply | Threaded
Open this post in threaded view
|

Re: How do I restrict mouse cursor movement area?

John Trinder
Ian,


Thanks very much for detailing how to convert a windows api to dolphin code.
I didn't realize that it's that EASY

Regards, John


Reply | Threaded
Open this post in threaded view
|

Re: How do I restrict mouse cursor movement area?

Bill Schwab-2
John,

> Thanks very much for detailing how to convert a windows api to dolphin
code.
> I didn't realize that it's that EASY

It often is that easy, but beware the complicated structure with lots of
pointers =:0   However, the type library analyzer can help with structs
given IDL based on a header file - see the Wiki for details.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: How do I restrict mouse cursor movement area?

Blair McGlashan
"Bill Schwab" <[hidden email]> wrote in message
news:ap6hi9$ro4n9$[hidden email]...
> John,
>
> > Thanks very much for detailing how to convert a windows api to dolphin
> code.
> > I didn't realize that it's that EASY
>
> It often is that easy, but beware the complicated structure with lots of
> pointers =:0   However, the type library analyzer can help with structs
> given IDL based on a header file - see the Wiki for details.

And if you are working with a Win32 API and need to generate a structure,
some kind souls have already put a lot of effort into defining a typelib for
pretty much the whole thing:
http://www.themandelbrotset.com/Technical/Typelib.asp

Note 1: Be aware that this typelibrary has been developed with VB in mind.
Since VB supports only a limited set of data types (e.g. no 32-bit unsigned
ints), some of the data types in the library may not be the same as those of
the published Win32 API. Often this is of now great concern, but it is worth
checking the resulting definitions against the Win32 docs (by reference to
msdn.microsoft.com). Even if the generated definitions have to be
"corrected" a little, I find that using this typelibrary saves one from the
tedious and error prone business of defining structure definitions by hand.

Note 2: Dolphin's typelib analyzer can be used to generate external method
call definitions (i.e. methods of the form you see in KernelLibrary,
UserLibrary, etc, that wrap external function calls), however this
functionality is not exposed through the ActiveX Component Wizard. For
example:
    tlb := AXTypeLibraryAnalyzer open: 'win.tlb'.
    "Enumerate all the modules in the library"
    tlb modules. "Ctrl+D"

    "Pick the User module (a TKindModuleAnalyzer)"
    user := tlb at: 'USER'.

    "Generate functions into the existing UserLibrary wrapper class"
    user globalName: #UserLibrary.

    "Generate the Chord() function"
    user generateMethodWrappers: (user functions select: [:each | each name
=
'ClipCursor']) first.

It is easier to generate a complete wrapper class for a particular "module"
(ExternalLibrary) by just sending #generate to the relevant
TKindModuleAnalyzer object, however that is probably not what one would want
to do in this case since there are literally hundreds of functions, most of
which one does not need.

Regards

Blair