KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

How to tell which border the mouse crossed at leaving?

 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Sun Jan 06, 2008 1:43 pm    Post subject: How to tell which border the mouse crossed at leaving? Reply with quote

How would one solve this the best way?

I need to keep track if the Mouse left the form at the left or right side, not interested in top and bottom leaves Smile

Furthermore I need to seperate between left and right leaves ... Oh and enters of course Mr. Green

OnMouseLeave and OnMouseEnter are there but how to tell (reacting on the event at the moment it happens) which side the mousepointer left the form ?

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
gbarnas
KiXforms Regular
KiXforms Regular


Joined: 07 Mar 2003
Posts: 41
Location: Mahwah, NJ

PostPosted: Mon Jan 07, 2008 1:58 pm    Post subject: Reply with quote

Can you get the mouse coordinates when the OnMouseLeave triggers?

If so, you know the form origin and size. If the coordinates are outside the form, you could tell left (< origin) or right (> origin+width).

You could also make a determination on the upper and lower boundaries. Figure on 8 quadrants - left, right, top, bottom, top-left, top-right, bottom-left, and bottom right. with that you can decide on whether to process it or not.

Glenn
Back to top
View user's profile Send private message Visit poster's website
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Mon Jan 07, 2008 2:04 pm    Post subject: Reply with quote

Hi Jochen,

Sorry, I don't think there is a way to track the mouse once it leaves the form.

But this might not be the end of the story, if you can, there might be an alternative. If you mount everything on a panel on the form you could track the mouse when it leaves the panel.

Here is an example:

Code:

;region Setup Variables
$Version = "Build(1.0.0.1)"
$System = CreateObject("Kixtart.System")
;endregion

Break on
If Not $System
   $= MessageBox("KiXforms Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf

;region Main Form
$Form = $System.Form()
$Form.OnMouseMove = "MouseMove()"
$Form.Size = 700,500
$Form.Text = "Basic Form $Version"

$MainPanel = $Form.Controls.Panel()
$MainPanel.BorderStyle = 1
$MainPanel.Size = 600,400

$Form.Center
$MainPanel.Center
$Form.Show()

;region Startup
;call some function
;endregion

While $Form.Visible
   $Error = Execute($System.DoEvents())
Loop
Exit 0
;endregion

;region Startup Functions

;endregion

;region Common Functions
Function MouseMove()
  Select
    Case $MainPanel.MouseX < 0 And $MainPanel.MouseY > 0 And $MainPanel.MouseY < $MainPanel.ClientHeight
      ? "Mouse Crossed Left Border."
      ? "" + $MainPanel.MouseX + "," + $MainPanel.MouseY
    Case $MainPanel.MouseX > $MainPanel.ClientWidth And $MainPanel.MouseY > 0 And $MainPanel.MouseY < $MainPanel.ClientHeight
      ? "Mouse Crossed Right Border."
      ? "" + $MainPanel.MouseX + "," + $MainPanel.MouseY
  EndSelect
EndFunction
;endregion

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Mon Jan 07, 2008 2:19 pm    Post subject: Reply with quote

After reading Glenn's post, I think he is right. Here is an example:

Code:

;region Setup Variables
$Version = "Build(1.0.0.1)"
$System = CreateObject("Kixtart.System")
;endregion

Break on
If Not $System
   $= MessageBox("KiXforms Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf

;region Main Form
$Form = $System.Form()
$Form.OnMouseLeave = "MouseMove('Leave')"
$Form.OnMouseEnter = "MouseMove('Enter')"
$Form.Size = 700,500
$Form.Text = "Basic Form $Version"

$Form.Center
$Form.Show()

;region Startup
;call some function
;endregion

While $Form.Visible
   $Error = Execute($System.DoEvents())
Loop
Exit 0
;endregion

;region Startup Functions

;endregion

;region Common Functions
Function MouseMove($EL)
  Select
    Case $Form.MouseX < 10 And $EL = 'Enter'
      ? "Mouse Entered From The Left Border."
    Case $Form.MouseX < 10 And $EL = 'Leave'
      ? "Mouse Left From The Left Border."
    Case $Form.MouseX > ($Form.ClientWidth - 10) And $EL = 'Enter'
      ? "Mouse Entered From The Right Border."
    Case $Form.MouseX > ($Form.ClientWidth - 10) And $EL = 'Leave'
      ? "Mouse Left From The Right Border."
    Case $Form.MouseY < 10 And $EL = 'Enter'
      ? "Mouse Entered From The Top Border."
    Case $Form.MouseY < 10 And $EL = 'Leave'
      ? "Mouse Left From The Top Border."
    Case $Form.MouseY > ( $Form.ClientHeight - 10 ) And $EL = 'Enter'
      ? "Mouse Entered From The Bottom Border."
    Case $Form.MouseY > ( $Form.ClientHeight - 10 ) And $EL = 'Leave'
      ? "Mouse Left From The Bottom Border."
  EndSelect
EndFunction
;endregion

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Jan 07, 2008 4:08 pm    Post subject: Reply with quote

Yap,

that seems to be the comfortable and secure way ... I'll try to implement and see if it decreases performance of the other event processing, ya know, I'd like to have at least 40 to 60 fps for eye relaxing purposes (need to test with 3 balls and a mass brick fading test environment Wink )

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Jan 07, 2008 7:10 pm    Post subject: Reply with quote

This seems to be promising :

Code:

function frm_MouseLeave()
    if $pnlMain.MouseY > 0 & $pnlMain.MouseY < $pnlMain.ClientHeight
        if $pnlMain.MouseX < 10
            $Paddle.Left = 0
        else
            if $pnlMain.MouseX > $pnlMain.ClientWidth       
                $Paddle.Left = $pnlMain.ClientWidth - $Paddle.ClientWidth
            endif
        endif
        if not $tmrSpeed.Enabled $Ball1.Left = $Paddle.Left + 16 endif
    endif
endfunction


Let's see how this performs under stress Smile

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group