delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/12/13:39:58

Message-ID: <33776349.2068@pobox.oleane.com>
Date: Mon, 12 May 1997 19:36:57 +0100
From: Francois Charton <deef AT pobox DOT oleane DOT com>
Organization: CCMSA
MIME-Version: 1.0
To: gary_cowell AT mickley DOT demon DOT co DOT uk
CC: djgpp AT delorie DOT com
Subject: Re: Newbie question on Allegro Buttons
References: <3371e478 DOT 8368557 AT news DOT demon DOT co DOT uk>

Gary Cowell (QI'HoS) wrote:
> 
> Hi..
> 
> What I want to be able to do is have a button that does not 'stick', I
> just want the button to be 'filled' when the mouse button is down, but
> 'cleared' when it is released again.
> 
> Any way of doing this? I can't find it in the allegro docs...
> 

You have to define your own d_mybutton_proc() GUI procedure, instead of 
using the default one. Here is how:

int d_mybutton_proc(int msg,DIALOG *d,int c)
{
int ret;

/* call the button as usual */
ret=d_button_proc(msg,d,0);
/* if it is selected, ie "black", then */
if(d->flags&D_SELECTED)
  {
  /* do whatever the button triggers: here is calls some function, in a
     table, and wait for the mouse button to be released */
  functable[d->d1]();
  while(mouse_b);
  /* deselect the button and redraw the button in white */
  d->flags^=D_SELECTED;
  show_mouse(NULL);
  d_button_proc(MSG_DRAW,d,0);
  show_mouse(screen);
  }
return  ret;
}

Hope this helps
Francois

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019