Condizioni di notifica
Evento notificato dall'albero quando un nodo viene tirato su un'altro nodo e l'albero non è di tipo Document Oriented. In questo caso, infatti, verrà notificato l'evento OnDropDoc.
Utilizzo consigliato
L'evento di OnDropNode viene normalmente utilizzato quando si vuol gestire il Drag&Drop tra nodi di un albero.
Argomenti
HashKey Sorgente | E' una stringa che identifica il nodo che è stato tirato. Per sapere cosa è un HashKey puoi leggere il paragrafo "Identificazione dei nodi: la proprietà HashKey" dell'articolo Nodi dell'albero. |
TreeIndex Sorgente | E' un numero intero che permette di identificare quale albero contiene il nodo che è stato tirato. L'evento viene notificato dall'albero che contiene il nodo che ha ricevuto il Drag&Drop. E' possibile confrontarlo con il risultato della funzione Me dell'albero per sapere di quale albero si tratta. |
HashKey Destinazione | E' una stringa che identifica il nodo su cui è stato tirato un nodo. Per sapere cosa è un HashKey puoi leggere il paragrafo "Identificazione dei nodi: la proprietà HashKey" dell'articolo Nodi dell'albero. |
Tasto Shift | E' un valore booleano che indica se, al termine dell'operazione di D&D, il tasto SHIFT era premuto. |
Tasto Alt | E' un valore booleano che indica se, al termine dell'operazione di D&D, il tasto ALT era premuto. |
Tasto Control | E' un valore booleano che indica se, al termine dell'operazione di D&D, il tasto CONTROL era premuto. |
Esempio di codice
// ****************************************************************************
// Fired when a node is dropped onto another node (only if the Drag And Drop
// propriety is True)
// ****************************************************************************
event AlberoCategorie.Categorie.OnDropNode(
string SourceHash // Hash Code of the node that has been dropped
int SourceTreeIndex // Index of the tree that contains the dropped no...
string DestinationHash // Hash Code of the node that received the drop
boolean ShiftKey // TRUE if the SHIFT key was pressed during the drop
boolean AltKey // TRUE if the ALT key was pressed during the drop
boolean ControlKey // TRUE if the CONTROL key was pressed during the...
)
{
string NomeSrc = "" //
string NomeDest = "" //
//
record Prodotto
...
//
// Recupero il nome del nodo sorgente/destinazione
NomeSrc := GetNodeName(SourceHash)
NomeDest := GetNodeName(DestinationHash)
//
// Se è stato tirato un prodotto su una categoria
if Left(SourceHash, C3) = PRO AND Left(DestinationHash, C3) = CAT
{
int IDProdotto = 0 //
int IDCatDest = 0 //
int IDCatSrc = 0 // Identifica la categoria corrente
string HashCatSrc = "" // Hash Key della categoria corrente
//
IDProdotto := ToInteger(Mid(SourceHash, C4, ??))
IDCatDest := ToInteger(Mid(DestinationHash, C4, ??))
//
// Recupero l'ID della categoria corrente
HashCatSrc := Categorie.GetParentNode(SourceHash)
IDCatSrc := ToInteger(Mid(HashCatSrc, C4, ??))
//
// Se il prodotto deve andare in una nuova categoria
if IDCatSrc <> IDCatDest
{
// Se è stato premuto CONTROL inserisco un nuovo prodotto
if ControlKey
...
else // Sposto il prodotto nella nuova categoria
...
//
// Aggiorno tutto l'albero
Categorie.RefreshNodes(??, ??)
//
// Espando il nodo di destinazione (qualora non lo fosse)
Categorie.ExpandNode(DestinationHash, ??, ??)
}
}
}
// Fired when a node is dropped onto another node (only if the Drag And Drop
// propriety is True)
// ****************************************************************************
event AlberoCategorie.Categorie.OnDropNode(
string SourceHash // Hash Code of the node that has been dropped
int SourceTreeIndex // Index of the tree that contains the dropped no...
string DestinationHash // Hash Code of the node that received the drop
boolean ShiftKey // TRUE if the SHIFT key was pressed during the drop
boolean AltKey // TRUE if the ALT key was pressed during the drop
boolean ControlKey // TRUE if the CONTROL key was pressed during the...
)
{
string NomeSrc = "" //
string NomeDest = "" //
//
record Prodotto
...
//
// Recupero il nome del nodo sorgente/destinazione
NomeSrc := GetNodeName(SourceHash)
NomeDest := GetNodeName(DestinationHash)
//
// Se è stato tirato un prodotto su una categoria
if Left(SourceHash, C3) = PRO AND Left(DestinationHash, C3) = CAT
{
int IDProdotto = 0 //
int IDCatDest = 0 //
int IDCatSrc = 0 // Identifica la categoria corrente
string HashCatSrc = "" // Hash Key della categoria corrente
//
IDProdotto := ToInteger(Mid(SourceHash, C4, ??))
IDCatDest := ToInteger(Mid(DestinationHash, C4, ??))
//
// Recupero l'ID della categoria corrente
HashCatSrc := Categorie.GetParentNode(SourceHash)
IDCatSrc := ToInteger(Mid(HashCatSrc, C4, ??))
//
// Se il prodotto deve andare in una nuova categoria
if IDCatSrc <> IDCatDest
{
// Se è stato premuto CONTROL inserisco un nuovo prodotto
if ControlKey
...
else // Sposto il prodotto nella nuova categoria
...
//
// Aggiorno tutto l'albero
Categorie.RefreshNodes(??, ??)
//
// Espando il nodo di destinazione (qualora non lo fosse)
Categorie.ExpandNode(DestinationHash, ??, ??)
}
}
}
- Attenzione: Se è attivata la Multi-selezione (parametro MultipleSelection) il sistema, dopo aver notificato l'evento OnDropNode per il nodo tirato, simula un'operazione di D&D di ogni altro nodo selezionato sul nodo che ha ricevuto il Drop notificando questo evento all'albero per ogni nodo tirato. In questo caso non è possibile effettuare un Refresh della struttura dell'albero altrimenti si potrebbe ottenere un errore.
Ultima modifica: 25/10/2016 / Validità: da 6.5.2680