Button Events

Discussion in 'Basic4ppc Wishlist' started by derez, Feb 22, 2009.

  1. derez

    derez Expert Licensed User

    Image Button control has ButtonDown and ButtonUp events.
    Why doesn't simple button have them as well ?
    I found it useful to do something continuously while the button is pressed:
    Code:
    Sub roll_down
    k = StrAt(
    Sender,4)
    roll_flag = 
    1
    Select k
      
    Case 1
       
    Do While roll_flag = 1
             rollX(delta)
             
    DoEvents
       
    Loop
    ...

    Sub roll_up
    roll_flag = 
    0
    End Sub
     
  2. Cableguy

    Cableguy Expert Licensed User

    I have 1 file name for you....
    DOOR.DLL
     
  3. derez

    derez Expert Licensed User

    From the Door Overview: "You should have some knowledge with the .Net Framework if you want to fully exploit this library."
    (I don't)

    OK, just tell me what I'm doing wrong here:
    Code:
    Sub Globals
    ' obj is object, BU and BD are events.

    End Sub

    Sub App_Start
    Form1.Show
    obj.New1(
    False)
    obj.FromControl(
    "Button1")
    BD.New1( obj.Value,
    "ButtonDown")
    BU.New1( obj.Value,
    "ButtonUp")
    End Sub

    Sub MD_NewEvent
        
    Msgbox("Button down")
    End Sub

    Sub MU_NewEvent
        
    Msgbox("Button Up")
    End Sub
     
  4. klaus

    klaus Expert Licensed User

    Here is the solution:

    Code:
    [SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff]Sub [/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Globals[/SIZE][/FONT]
    [/SIZE][/
    FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]'Declare the global variables here.[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  x=[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  y=[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
     
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]App_Start[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  Form1.Show[/FONT][/SIZE]
    [SIZE=
    2][FONT=Courier New]  obj.New1([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]False[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  obj.FromControl([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Button1"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  BD.New1( obj.Value,[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"MouseDown"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  BU.New1( obj.Value,[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"MouseUp"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [/SIZE][/
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
     
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]BD_NewEvent[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  obj.Value=BD.Data[/FONT][/SIZE]
    [SIZE=
    2][FONT=Courier New]  x=obj.GetProperty([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"X"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  y=obj.GetProperty([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Y"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  Label1.Text=[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"MouseDown x="[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]&x&[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]" y="[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]&y[/SIZE][/FONT]
    [/SIZE][/
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
     
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]BU_NewEvent[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  obj.Value=BU.Data[/FONT][/SIZE]
    [SIZE=
    2][FONT=Courier New]  x=obj.GetProperty([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"X"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  y=obj.GetProperty([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Y"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  Label1.Text=[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"MouseUp x="[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]&x&[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]" y="[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]&y[/SIZE][/FONT]
    [/SIZE][/
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT]
    The events ButtonDown and ButtonUp don't exist !

    Be aware that the Mouse events for Buttons are NOT supported on the device.

    Attached the small demonstration program.

    Best regards.
     

    Attached Files:

  5. derez

    derez Expert Licensed User

    Klaus
    Thanks, It is a solution but if you look at the first post - it is a very complicated solution in comparison to using an image button which does have these events, and I wonder why they do not exist for simple button control.

    Also , I don't understand why the door cannot implement the existing events on the button. I understand that this is what the library was created for (to add where B4Ppc does not provide).
     
    Last edited: Feb 24, 2009
  6. agraham

    agraham Expert Licensed User

    Because a Button is a standard .NET Button control but ImageButton is a custom control written by Erel for Basic4ppc. Because of this it has access to the mouse events which a normal Button does not have.

    The Door library can implement any existing events whose EventArgs (the Door Data property) it can understand, which is most events. The events you are referring to do not exist on a .NET Button in the Compact Framework. For some reason known only to Microsoft it has KeyDown, KeyPress and KeyUp events you could implement using a Door Event but none of the mouse events.
     
  7. derez

    derez Expert Licensed User

    thank you for the explanation.

    I'll state my wish in another way : "My wish is that Erel will create a B4Ppc button that will have the up and down events like those of its privileged brother, the Imagebutton."

    :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice