Look at this example:

|RequestTimedRefresh( 1 );
LeftButton = GetCursorMouseButtons() & 1;
reset = GetCursorMouseButtons() &4 ; // middle button pressed

numClicks = Nz( StaticVarGet( "counter" ) );

*if* ( leftButton )
StaticVarSet( "counter", numClicks + 1 );

*if* (reset )
{
    StaticVarSet( "counter" ,0);
*    Title* = "Counter Reseted !" ;
}
*else*

*Title* = "Clicks Counter: " + StaticVarGet( "counter" );|

On 11/7/2009 6:58 PM, Reinsley wrote:
Hello,

I would like to decrease Myparam of 0.25 on each clic inside the red button.

I complicated with static var but Myparam comes back to 5 as it is declared at 
the beginning of the formula.

How to decrease a var with a GFX button ?

To give an idea of what I want to do , once this point solved, my next step 
will be to increase of 0.25 the same Myparam with a Plus button to adjust a 
Fibonacci step. I will add Fibonacci code at the very end.

AB parameters windows lacks some ergonomics in real time.

I draw the buttons in the upper right side, after the bars, as quote marker 
will not be activate.

Thanks for the help

Best regards




// draw a red square + inside click

//SetChartOptions( 2, chartHideQuoteMarker );

Myparam = Param( "TheValue", 5, 0, 5, 0.25 );
StaticVarSet( "Myparamstat ", Myparam );

Myparam = StaticVarGet( "Myparamstat " );
_TRACE( "Myparamstat = " + Myparam );


function DrawButton( Text, x1, y1, x2, y2, BackColor )
{
     GfxSetOverlayMode( 0 );
     GfxSelectFont( "Tahoma", 12, 800 );
     GfxSelectPen( colorBlack );
     GfxSetBkMode( 1 );
     GfxSelectSolidBrush( BackColor );
     GfxSetBkColor( BackColor );
     GfxSetTextColor( 1 );
     GfxRectangle( x1, y1, x2, y2 );
     GfxDrawText( Text, x1, y1, x2, y2, 32 | 1 | 4 );
}

shift = 40;
XOffset  = StaticVarGet( "XOffset" );
YOffset  = StaticVarGet( "YOffset" );

pxchartwidth = Status( "pxchartwidth" );
XOffset  = pxchartwidth - shift ; // X1
YOffset  = 0;//Y1
SquareSide = 20;

X1m = XOffset  ;
X2m = Xoffset + SquareSide ;
Y1m = YOffset  ;
Y2m = yOffset + SquareSide ;

DrawButton( "-", Xoffset, yOffset, Xoffset + SquareSide , yOffset + SquareSide 
, colorRed );

LButtonTrigger  = GetCursorMouseButtons() == 9;
_TRACE( "LButtonTrigger = " + LButtonTrigger );

if ( LButtonTrigger )
{
     MousePx  = Nz( GetCursorXPosition( 1 ) );
     MousePy  = Nz( GetCursorYPosition( 1 ) );

     CursorInMinus = MousePx>  X1m AND MousePx<  X2m AND MousePy>  Y1m AND 
MousePy<  Y2m;
     _TRACE( "CursorInMinus = " + CursorInMinus );

     if ( CursorInMinus )
     {
         DrawButton( "-", Xoffset, yOffset, Xoffset + SquareSide , yOffset + 
SquareSide , colorYellow );
         Myparam = StaticVarGet( "Myparamstat " );
         Myparam = Myparam - 0.25;
         _TRACE( "Myparamstat2 = " + Myparam );
         RequestTimedRefresh( 1 );
     }
}








------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links




Reply via email to