locked
[POC][RS]: Four state button proof of concept with dynamic location - updated (29/12/2008) RRS feed

  • General discussion

  • Title: Four state button with dynamic location
    Stage: Proof of concept
    Author: Pacolaco
    Date: 29/12/2008
    Version: 1.1

    Todo:
    Get Image height and width, so they can put in whatever images they'd like.
    Make a three state button (Mouse over, !mouse over, and Mouse Down Over)
    Make a two state button (Mouse Over, !mouse over)
    make a one state button (Gee that'll be hard, just a static button)


    Description: A proof of concept for a 4 state button. The states are Mouse Over (MO), Mouse Not Over (MNO), Mouse Down Over (MDO), and Mouse Down Not Over (MDNO). The program checks for mouse movement, mouse clicks, and mouse overs, or lack thereof. In the current state, it doesn't seem like the method I have would be good for too many buttons, although testing still needs to be done. The program recognizes mouse overs, clicks, and click mouse out with great speed on many computers. There are Button1X and Button1Y variables that can be changed so you can place the button where you'd like, and the mouse constraints will update accordingly.


    Idea: I couldn't find any built in methods for buttons, so while I was in school I wrote down some psuedo code, then began to write the actual code, on paper. The dynamic idea came, because I decided it's too difficult to change so many things just to shift the button a couple pixels (or a whole bunch).


    Time: About 2 hours for testing, restyling buttons, designing the 3x3 random color palette, writing this post, and uploading.


    Questions: None so far :(.


    Download Includes:
    1. ButtonStates\MO.BMP
    2. ButtonStates\MNO.BMP
    3. ButtonStates\MDO.BMP
    4. ButtonStates\MDNO.BMP
    5. Button click Examplev1.1.sb
    6. V1.1.txt
    Download link (Rapidshare.com):

    http://rapidshare.com/files/177885503/4_State_button_V1.1.rar

    Thanks!
     Andrew (Pacolaco)

    Old versions:

    V1.0 (14/11/2008)
    http://rapidshare.com/files/163876473/Button-POC.rar

    • Edited by Pacolaco Monday, December 29, 2008 5:04 PM
    Saturday, November 15, 2008 1:42 AM

All replies

  • Wow!!!  Sweet!  This even gets the click+drag behavior right.

    Here's a Zip version for direct download:

    http://smallbasic.com/drop/buttonclick.zip

    And here's the screenshot.

    Saturday, November 15, 2008 3:53 AM
  • Thanks for the compliments Vijaye, next time I do a POC I'll try and provide a picture among other things :).

    I did a little bit of.. research on buttons. I was thinking 3 states, Mouse not over, mouse over, mouse down. Then I saw something about 4 state buttons, and I was a bit confused until I read about clicking and dragging off. This was actually a little bit of a pain to make. I suspect with the next Small Basic release, I'll be able to create quite a few more POCs.
    Saturday, November 15, 2008 5:15 AM
  • Unfortunately I get a generic '...has encountered a problem and needs to close' error when I click the Run (F5) button.
    It seems to be related Load Images section because when I rem those lines out (remark them by placing ' in front) I don't get the error until after the graphics window opens.

    I am at work and they have unique Windows builds as well as all sorts of plugg-ins for different software.
    Maybe it will work at home.

    FYI: all my other sample programs are working, as well as a Pong game I am writing (not that you can't download a Pong type game almost anywhere on the internet, just wanted to see if I can program it).

    • Edited by Path_drc Monday, November 17, 2008 8:38 PM
    Monday, November 17, 2008 8:35 PM
  • You need to put the right paths to the images in the first 4 LoadImage calls.  For example,

    If you extracted all the images to c:\, 

        ImageList.LoadImage("MNO" , "Change to reflect path of MNO.BMP" )

    should be changed to something like:

        ImageList.LoadImage("MNO" , "c:\MNO.BMP" )
    Tuesday, November 18, 2008 3:15 AM
  • Thanks for answering, Vijaye.

    Vijaye is right, you must change the ImageList.LoadImage to where the images are for this to work.
    Tuesday, November 18, 2008 4:09 AM
  • Wow, I just downloaded small basic today.  I guess this post answers my questions.

    Microsoft didn't even implement a mouse button.

    in my opinion that makes small basic very complicated to do even the simplest of tasks.

    One should not have to program their own mouse button.
    Saturday, December 27, 2008 6:22 AM
  • One doesn't have to, I'll do it for them.
    Monday, December 29, 2008 4:24 PM