locked
Controls, Buttons in particular RRS feed

  • Question

  • My first encountered problem when trying to use some buttons in the graphics window is that how to use the Controls.ButtonClicked.  The compiler keeps telling me "The operator Conrols.ButtonClicked is undefined."

    My second problem is that I don't understand the relashionship between buttons and the graphicswindow's colors.  I want a black button background with yellow text.  The rest of the GraphicsWindow has a black background.  Instead of getting yellow text, it comes out blue on a white background in the button.

    I have searched, trying to find a sample program that uses buttons, but to no avail.

     


    RussPC
    Friday, December 2, 2011 9:10 PM

Answers

  • I don't think you can change the button background colour (without an extension), but the font and colour can be changed.

    Simple program with several buttons below with random colour (brush) text.

    numButton = 6
    For i = 1 To numButton
      GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
      button[i] = Controls.AddButton("Button "+i,50,50*i)
    EndFor
    Controls.ButtonClicked = OnButtonClicked

    Sub OnButtonClicked
      lastButton = Controls.LastClickedButton
      For i = 1 To numButton
        If (lastButton = button[i]) Then
          GraphicsWindow.ShowMessage("Button "+i+" pressed", "Information")
        EndIf
      EndFor
    EndSub

    Friday, December 2, 2011 9:40 PM

All replies

  • I don't think you can change the button background colour (without an extension), but the font and colour can be changed.

    Simple program with several buttons below with random colour (brush) text.

    numButton = 6
    For i = 1 To numButton
      GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
      button[i] = Controls.AddButton("Button "+i,50,50*i)
    EndFor
    Controls.ButtonClicked = OnButtonClicked

    Sub OnButtonClicked
      lastButton = Controls.LastClickedButton
      For i = 1 To numButton
        If (lastButton = button[i]) Then
          GraphicsWindow.ShowMessage("Button "+i+" pressed", "Information")
        EndIf
      EndFor
    EndSub

    Friday, December 2, 2011 9:40 PM
  • Just gonna explain the first problem a bit more, branching off of litdev's answer

    Your "Operator ButtonClicked is undefined" problem is probably because you don't have a subroutine with matching names:

     

    Controls.ButtonClicked=Clicked 'This is where you set the event handler subroutine's name

    Sub Clicked 'This is the event handler subroutine

    EndSub


    ~~AirWaves!!~~
    Saturday, December 3, 2011 2:55 AM
  • Thank you!  That helps.

    I'm still murky about what color settings affect which parts of the Graphics Window.  I would think that BrushColor would affect backgrounds (I think this is stated in some of the documentation) and PenColor would apply to lines and text.  I believe this is the association in other languages (not sure, though).

    I guess this is another "trickle down" situation.  Knowledge trickles down from the experienced to the noob.  But the noob has to know what to ask.

     


    RussPC
    Saturday, December 3, 2011 12:33 PM
  • Thanks, but that wasn't the situation, which was a couple of days ago, and I have since changed things around.  At any rate, the problem no longer plagues me.  For a while; I can't vouch for the future!~

     


    RussPC
    Saturday, December 3, 2011 12:34 PM