Code : Tout sélectionner
Procedure onPlot()
; Parcours de la grille de plots
Protected x, y
; Position x y de la souris
Protected px = GetGadgetAttribute(#mfGrid, #PB_Canvas_MouseX)
Protected py = GetGadgetAttribute(#mfGrid, #PB_Canvas_MouseY)
; Plot en cours de traitement
Static PreviousPlot.i
; Action a effectuer 0 (Aucune, 1 : Selection, 2 : Déselection)
Static CurrentAction.i
; La Souris est sur la grille : Affichage de la main
If EventType() = #PB_EventType_MouseEnter
SetGadgetAttribute(#mfGrid, #PB_Canvas_Cursor, #PB_Cursor_Hand)
EndIf
; La souris est en mouvement et la touche gauche de la soutis est préssée
If (EventType() = #PB_EventType_MouseMove And
GetGadgetAttribute(#mfGrid, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
StartDrawing(CanvasOutput(#mfGrid))
; Parcours de la grille
For x = 0 To gnbCol - 1
For y = 0 To gnbLig - 1
With Grid(x,y)
; Le surseur de la souris est sur un plot
; Ce nouveau plot doit etre différent du précédent
If (px > \x0 And py> \y0 And px < \x1 And py < \y1) And (Grid(x,y) <> PreviousPlot)
; C'est un nouveau plot. Mémorisation du plot en cours
PreviousPlot = Grid(x,y)
; Action à effectuer
; 0 : On ne sait pas encore
; 1 : Le plot sera sélectionné
; 2 : Le plot sera déselectionné
If CurrentAction = 0
If \isSelect = #False
CurrentAction = 1
Else
CurrentAction = 2
EndIf
EndIf
If CurrentAction = 1
;StartDrawing(CanvasOutput(#mfGrid))
Box(\x0 + pSpace, \y0 + pSpace, pInnerSize, pInnerSize, PlotColorActif)
;StopDrawing()
\isSelect = #True
EndIf
If CurrentAction = 2
;StartDrawing(CanvasOutput(#mfGrid))
Box(\x0 + pSpace, \y0 + pSpace, pInnerSize, pInnerSize, PlotColorInactif)
;StopDrawing()
\isSelect = #False
EndIf
EndIf
EndWith
Next
Next
StopDrawing()
EndIf
; Le bouton gauche de la souris est relaché
If EventType() = #PB_EventType_LeftButtonUp
PreviousPlot = #False
CurrentAction = 0
EndIf
EndProcedure
** À moins que je m' auto-suggestione

.
Y'a plus qu'à intégrer ça dans mon ébauche et y ajouter la gestion du MIDI ...



.