I am having a problem with the ON CHANGE clause of the Radio class(es). It seems the ON CHANGE event is firing when the dialog or window containing the Radio button is updated, even when the value is unchanged. Is this by design or a bug?
Thanks.
// Radio Buttons management sample
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oRadMenu
local nOption := 2
SET _3DLOOK ON
DEFINE DIALOG oDlg RESOURCE "Radios"
REDEFINE RADIO oRadMenu VAR nOption ID 110, 120, 130, 140, 150 OF oDlg ;
ON CHANGE MsgInfo( "Hello" ) ;
UPDATE
REDEFINE BUTTON ID 100 OF oDlg ACTION oRadMenu:GoNext() ;
WHEN nOption == 3
REDEFINE BUTTON ID 102 OF oDlg ACTION oRadMenu:GoPrev()
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( oDlg:Refresh(), oDlg:Update() )
SET _3DLOOK OFF
return nil
//----------------------------------------------------------------------------//
METHOD nOption( nNewOption ) CLASS TRadMenu
if nNewOption != nil
Eval( ::bSetGet, nNewOption )
if ::bChange != nil
Eval( ::bChange, Self ) /* <--- This runs every time the container is updated or painted */
endif
else
return Eval( ::bSetGet )
endif
return nil
METHOD nOption( nNewOption ) CLASS TRadMenu
if nNewOption != nil
IF Eval( ::bSetGet ) != nNewOption /* <----- Added this to check if we even need an update, value may already be set!! */
Eval( ::bSetGet, nNewOption )
if ::bChange != nil
Eval( ::bChange )
endif
ENDIF
else
return Eval( ::bSetGet )
endif
return nil
... ON INIT ( oDlg:Refresh(), oDlg:Update() )
// Radio Buttons management sample
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oRadMenu
local nOption := 2
SET _3DLOOK ON
DEFINE DIALOG oDlg RESOURCE "Radios"
REDEFINE RADIO oRadMenu VAR nOption ID 110, 120, 130, 140, 150 OF oDlg ;
ON CHANGE MsgInfo( "Hello" ) ;
UPDATE
REDEFINE BUTTON ID 100 OF oDlg ;
ACTION oDlg:Update()
REDEFINE BUTTON ID 102 OF oDlg ;
ACTION oDlg:Update()
ACTIVATE DIALOG oDlg CENTERED
SET _3DLOOK OFF
return nil
//----------------------------------------------------------------------------//
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 54 guests