Hello,
In our program we have an TIconGroup and we see that when it is empty it crashes if you press a key.
the method:
should be fixed in this way
Personally I would have used the aCoors to select next icon based on keys...

In our program we have an TIconGroup and we see that when it is empty it crashes if you press a key.
the method:
METHOD KeyDown( nKey, nFlags ) CLASS TIconGroup
local nAt := ::nFocused
local nLen := Len( ::aIcons )
local cPrompt := ::aPrompts[ nAt ]
do case
case nKey == VK_UP .or. nKey == VK_LEFT
if --nAT < 1
nAt = nLen
endif
::ChangeFocus( nAt )
Eval( ::oVScroll:bGoUp )
return 0
case nKey == VK_DOWN .or. nKey == VK_RIGHT
if ++nAT > nLen
nAt = 1
endif
::ChangeFocus( nAt )
Eval( ::oVScroll:bGoDown )
return 0
case nKey == VK_HOME
::ChangeFocus( 1 )
return 0
case nKey == VK_END
::ChangeFocus( nLen )
return 0
case nKey == VK_RETURN
Eval( ::aActions[ nAt ], Self )
return 0
case nKey == VK_F2
if ::lAutoEdit
::lEdit := .t.
::EditPrompt( nAt, cPrompt,;
{|uVar| if( uVar != nil, ::aPrompts[ nAt ] := uVar, ), ::DrawIcon( nAt ) },;
GetSysColor( COLOR_WINDOWTEXT ), GetSysColor( COLOR_CAPTIONTEXT ) ) // ::nClrText, ::nClrPane
return 0
endif
endcase
return ::Super:KeyDown( nKey, nFlags )should be fixed in this way
METHOD KeyDown( nKey, nFlags ) CLASS TIconGroup
local nAt := ::nFocused
local nLen := Len( ::aIcons )
local cPrompt
if nLen = 0 //<-- added
return //<-- added
endif //<-- added
if nAt = 0 //<-- added
nAt:=1 //<-- added
endif //<-- added
do case
case nKey == VK_UP .or. nKey == VK_LEFT
if --nAT < 1
nAt = nLen
endif
::ChangeFocus( nAt )
Eval( ::oVScroll:bGoUp )
return 0
case nKey == VK_DOWN .or. nKey == VK_RIGHT
if ++nAT > nLen
nAt = 1
endif
::ChangeFocus( nAt )
Eval( ::oVScroll:bGoDown )
return 0
case nKey == VK_HOME
::ChangeFocus( 1 )
return 0
case nKey == VK_END
::ChangeFocus( nLen )
return 0
case nKey == VK_RETURN
Eval( ::aActions[ nAt ], Self )
return 0
case nKey == VK_F2
if ::lAutoEdit
cPrompt := ::aPrompts[ nAt ] //<-- moved
::lEdit := .t.
::EditPrompt( nAt, cPrompt,;
{|uVar| if( uVar != nil, ::aPrompts[ nAt ] := uVar, ), ::DrawIcon( nAt ) },;
GetSysColor( COLOR_WINDOWTEXT ), GetSysColor( COLOR_CAPTIONTEXT ) ) // ::nClrText, ::nClrPane
return 0
endif
endcase
return ::Super:KeyDown( nKey, nFlags )Personally I would have used the aCoors to select next icon based on keys...