Drag and Drop verbieten

  • In einer Tabelle kann man Text markieren und den mit der Maus an eine andere Position verschieben (auch in eine andere Zelle).

    Das möchte ich verbieten!

    Nehme ich in WPToolBar1.sel_EditIcons das Copy/Cut/Paste raus ändert das leider gar nichts außer dass die Buttons verschwinden.
    Der Benutzer soll aber immer noch innerhalb einer Zelle Textteile markieren und mit Del/Cut/Copy bearbeiten dürfen, nur das Verschieben mit der Maus soll verhindert werden!

    Wie kann ich das erreichen?

    Ciao

    Stefan

    • Offizieller Beitrag

    This event is triggered before a drag&drop operation is started.

    The parameter DoIt will default to false if no text is selected or the selected

    text is a range of table cells. DragMode must be set to "dmManual"! :

    property OnQueryDrag: TWPQueryDragEvent;

    Mit diesem Event können Sie also -selektiv- verbieten dass eine Drag Operation getartet wird.

    Das event BeforeDropText erlaubt -selektiv- das ablegen des Textes:

    TWPOnBeforeDropText = procedure(Destination: TWPCustomRtfEdit; X, Y: Integer;

    par: TParagraph; posinpar: Integer; Source: TWPCustomRtfEdit;

    var Abort: Boolean) of object;

    Hier kann auch der formattierte quell text an den Zieltext angepasst eingefügt werden.

    • Offizieller Beitrag

    Ansonsten gibt es noch die property ClipboardOptions mit verschiedenen Flags: u.a. wpcoNoInternalDragAndDrop


    TWPClipboardOptions = set of

    (wpcoNoInternalDragAndDrop, // V5: Switch off the internal drag&drop

    wpcoNoDragAndDropFromOutside, // V5: Allow only Drop from within

    wpcoAlwaysDeleteInDragSource, // Delete dragged source text if from different editor, too!

    wpcoDontMoveCursorDuringDrag, // Do not show cursor when dragging

    wpcoNoAutoSelSpaceExtension, // Don't select preceding or trailing spaces when doing Drag&Drop

    wpDontHideCaret, // do not hide the caret while selection is active

    wpcoDontPasteWPT, wpcoDontPasteRTF, wpcoDontPasteANSI, wpcoDontPasteUNICODE, wpcoDontPasteHTML,

    wpcoPasteHTMLWhenAvailable, // Paste HTML even if RTF is available (unless wpcoDontPasteHTML was set)

    wpcoDontPasteGraphics,

    wpcoDontCopyRTF, wpcoDontCopyANSI, wpcoDontCopyUNICODE, wpcoDontCopyWPTOOLS, wpcoPreserveBorders, wpcoPreserveShading,

    wpcoPreserveIndents,

    wpcoDontAutoAppendSpace,

    wpcoPasteAsNestedTable, // V5.13.5 - cells are always pasted as nested table

    wpcoDontPasteFonts, wpcoDontPasteFontSizes,

    wpcoDoNotUseInsertMode, // Any paste operation will completely replace the document!

    wpcoDontCopyProtectedText, // Do not copy protected text - independently to ppProtectSelectedTextToo

    wpcoDontCopyProtectedAttribute, // Do not save the afsProtected Attribute

    wpcoAlwaysCopyImagesEmbedded, // Copy BLOB data for linked images

    wpcoAlsoCopyHTML, // also copy HTML to clipboard

    wpcoAlsoPasteRTFVariables, //5.24.2 Per default don't load RTF variables from clipboard

    wpcoDontPasteWhenTextIsSelected,

    wpcoPastedANSIDoesNotInheritParAttr // By default, when pasting ANSI text the new paragraphs inherit the current paragraph attributes

    );