VB.net在Wince5.0下达成自定义控件的MouseLeave事件

2.获得控件的rectangle区域的荧屏坐标 Dim rect As Rectangle =
Me.RectangleToScreen(Me.ClientRectangle)。

1.创造贰个类承接LinearLayout

      Dim rect As Rectangle = Me.RectangleToScreen(Me.ClientRectangle)
        If rect.Contains(Control.MousePosition.X,
Control.MousePosition.Y) = False Then
            RaiseEvent mouseleave()
        End If
End Sub 

 3.编辑toolbar的控件事件:

http://www.bkjia.com/VBjc/525728.htmlwww.bkjia.comtruehttp://www.bkjia.com/VBjc/525728.htmlTechArticle主要就是要获取当前鼠标位置是否还在控件的rectangle区域内;实现步骤:
1.获得当前鼠标的荧屏坐标用:Control.MousePosition.X,
Control.MousePosi…

<com.firstlinetestapp.ui.view.TitleLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

end sub

 

  Private Sub PictureButton_MouseMove(ByVal sender As Object, ByVal
e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
        Me.Timer1.Enabled = True
    End Sub

 

看清鼠标当前是否离开代码如下:

以title控件为例

    Public Event mouseleave()
    Dim flagleave As Boolean = False

2.在activity.xml中引用:

摘自  执着于本身的执着 

class TitleLayout(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {

    init {
        LayoutInflater.from(context).inflate(R.layout.title,this)

        title_back.onClick {
            val c = getContext() as Activity
            c?.finish()
        }

        title_edit.onClick {
            Toast.makeText(getContext(), "Clicked Edit button", Toast.LENGTH_SHORT).show()

        }
    }

}

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
        If flagleave = False Then
            flagleave = True
            Me.mouseover = True
            Me.Invalidate()
        End If

  Public Sub mouseleave_leave() Handles Me.mouseleave
        Me.mouseover = False
        Me.Invalidate()
        flagleave = False
        Timer1.Enabled = False
    End Sub

在自定义控件时累加三个定时器,起初设置为不可用。间隔100ms,况且在自定义控件的onpaint方法中重写重绘按键表面代码,即重写这几个艺术:

重中之重正是要获取当前鼠标地点是或不是还在控件的rectangle区域内;达成步骤:

1.收获当前鼠标的显示器坐标用:Control.MousePosition.X,
Control.MousePosition.Y。

3.确定当前获得的鼠标是或不是在上头获得的控件的荧屏坐标区域内If
rect.Contains(Control.MousePosition.X, Control.MousePosition.Y) = False
Then  Raise伊芙nt mouseleave()。

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
重绘表面代码

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图