quando se coloca um mouse ativo, é preciso tratar todos os eventos dele, alem daqueles de teclado que já tratávamos. É preciso definir areas de tela e as respectivas ações para um click nestas áreas. Infelizmente a máquina não adivinha o que queremos fazer após apertar um botão do mouse...
Já peguei sistemas desenvolvidos sem apoio para mouse e coloquei, através da SuperLib. É só substituir as funções tradicionais pelas da lib e acrescentar alguns tratamentos.
Boa sorte e disponha.
Código: Selecionar todos
//--- Menu To para RAT_MENU2
local aOptions := { ;
{23,2 , 'Add'},;
{23,9 , 'Open'},;
{23,17 , 'Delete'},;
{23,27 , 'Change Date'},;
{23,42 , 'Output list'},;
{23,57 , 'Purge '},;
{23,74 , 'Quit'}}
nSelected := RAT_MENU2(aOptions,4,.f.,{|r,c| checkmouse(r,c) })
// --- Achoice() para MChoice()
aMeals := {"Pizza","Chicken","Chinese"}
nSelect := mchoice(aMeals)
// or box with title
aMeals := {"Pizza","Chicken","Chinese"}
nSelect := mchoice(aMeals,,,,"Meals")
// or box with title, first letter match = return and top/left specified
aMeals := {"Pizza","Chicken","Chinese"}
nSelect := mchoice(aMeals,10,10,,,"Meals",.t.)
//to retain element and position between calls
nSelect := 1
nRow := 1
aMeals := {"Pizza","Chicken","Chinese"}
while nSelect > 0
nSelect := mchoice(aMeals,,,,,"Meals",.t.,nSelect,@nRow)
// code
endif
// READ para RAT_READ()
v1 := space(10)
v2 := space(10)
v3 := space(10)
@10,10 get v1
@11,10 get v2
@12,10 get v3
// read, starting at get # 2, wrapping, and interpreting the right
// mouse button as chr(27) (escape).
RAT_READ(getlist,2,.T.,27)
// TBrowse() ==> Tratamento de eventos
while .t.
dispbegin()
while !oTb:stabilize()
end
nRow := ROW()
nCol := COL()
nRecnoOld := recno()
cfieldName := aFields[oTb:colpos]
cFieldDes := aFdescr[oTb:colpos]
cDeleted := IIF(DELETED()," [Deleted]"," ")
dispend()
nLKey := rat_event(0) // ====> AGUARDA POR UM EVENTO DE MOUSE OU TECLADO...
nMouseR := rat_eqmrow()
nMouseC := rat_eqmcol()
nButton := MOUSEHOTAT(nMouseR, nMouseC, aButtons)
cLkey := upper(chr(nLkey))
if nButton > 0
cLkey := upper(chr(nButton))
endif
do case
case nLkey == K_DOWN .or. nButton==K_DOWN
oTb:down()
IF nButton==K_DOWN
IFMOUSEHD({||oTb:down()},oTb) // ===> CONTINUA oTb:down() enquento botão apertado
ENDIF
case nLkey == K_PGDN
oTb:pagedown()
case nLkey == K_UP .or. nButton==K_UP
oTb:up()
IF nButton==K_UP
IFMOUSEHD({||oTb:up()},oTb) // ===> CONTINUA oTb:up() enquento botão apertado
ENDIF
case nLkey == K_PGUP
oTb:pageup()
case nLkey == K_CTRL_PGUP
oTb:gotop()
case nLkey == K_CTRL_PGDN
oTb:gobottom()
case nLkey == K_LEFT .or. nButton==K_LEFT
oTb:left()
IF nButton==K_LEFT
IFMOUSEHD({||oTb:left()},oTb)
endif
case nLkey == K_RIGHT .or. nButton==K_RIGHT
oTb:right()
IF nButton==K_RIGHT
IFMOUSEHD({||oTb:right()},oTb)
endif
case nLkey == K_CTRL_RIGHT
oTb:panright()
case nLkey == K_CTRL_LEFT
oTb:panleft()
case nLkey == K_HOME
oTb:home()
case nLkey == K_END
oTb:end()
case nLkey == K_CTRL_END
oTb:colpos := oTb:colcount
oTb:refreshall()
case nLkey == K_CTRL_HOME
oTb:colpos := 1
oTb:refreshall()
CASE nLkey = K_ESC
EXIT
CASE nLkey = K_F1 .or. nbutton==K_F1
db_navig()
CASE (cLkey==Chr(K_DEL)) // .OR. cLkey=="R") .AND. lAddEdit
IF LastRec() > 0
delrec()
SKIP -1
SKIP 1
oTb:refreshall()
else
msg("Arquivo vazio...")
endif
CASE nLKey == 13 .and. LastRec()==0
msg("Arquivo vazio...")
case MBRZMOVE(oTb,nMouseR,nMouseC,6,1,19,78) // ===> TRATA CLICK NAS CELULAS DO TBROWSE
CASE MBRZCLICK(oTb,nMouseR,nMouseC) // ===> TRATA CLICK NA CELULA ATIVA DO TBROWSE
keyboard chr(K_ENTER)
endcase
End