It's difficult for me to find out what's wrong in what you did because 1) v5 is no longer supported 2) your 0docbook5.xxe starts by including "_docbook5.xxe" which I don't have.

However please find attached to this email a mockup of what you did which works fine in XXE v6.1.

I see no reason why, after recompiling this mockup against v5.9, this would not work there too.

--> Because the BACK_SPACE and DELETE binding are found in the stock docbook5.xxe, I had to put the customized bindings in custom 0docbook5.xxe. It indeed does not work as expected when these bindings are added to customize.xxe.

--> Mockup command "geresoDelete" is of course also declared in custom 0docbook5.xxe. In fact my custom 0docbook5.xxe contains what follows:

---
  <include location="docbook5-config:docbook5.xxe"/>

  <command name="geresoDelete">

<class>com.calenco.xxe.ext.CustomDeleteSelectionOrJoinBlockOrDeleteChar</class>
  </command>

  <command name="deleteSelectionOrJoinBlockOrDeleteChar">
    <macro>
      <sequence>
        <command name="geresoDelete" parameter="%0 %1" />
      </sequence>
    </macro>
  </command>

  <binding>
    <keyPressed code="BACK_SPACE" />
    <command name="deleteSelectionOrJoinBlockOrDeleteChar"
             parameter="keypress backwards" />
  </binding>

  <binding>
    <keyPressed code="DELETE" />
    <command name="deleteSelectionOrJoinBlockOrDeleteChar"
             parameter="keypress" />
  </binding>
---



On 01/07/2015 04:32 PM, Fabián Mandelbaum wrote:
Thanks a lot for your support. I've managed to do something like what we
need, but I'm still facing an issue (small, but kinda show-stopper).

I've programmed in Java two custom delete commands: CustomDelete, to
replace the standard Delete command, and
CustomDeleteSelectionOrJoinBlockOrDeleteChar to replace
DeleteSelectionOrJoinBlockOrDeleteChar using my CustomDelete
implementation (where the "real" work happens).

I'm using XXE 5.9.0 because that's what we're (still, shame on us...)
deploying to our customers (and cuz I don't have XXE 6.1 sources
handy... shame on me...).

The custom command works as expected, no problem with that (but I'm
attaching their sources so you can inspect them if you feel like doing so).

However, the customize.xxe bindings to the BACK_SPACE and DEL keys do
not work as expected. What I had to do is to bind them with the "mod"
modifier (Ctrl/Cmd key) to have them work. If I bind them without any
modifier (which is what I really need), they are ignored, the 'standard'
binding is executed instead (or, said differently: my custom
deleteSelectionOrJoinBlockOrDeleteChar definition is not executed). I'm
also attaching my customize.xxe for your close inspection if needs be
(it's basically the standard one, fully commented out, plus my
customizations at the end).

So, bottomline:

<binding>

     <keyPressed code="BACK_SPACE" modifiers="mod" />

     <command name="deleteSelectionOrJoinBlockOrDeleteChar"
parameter="keypress backwards" />

   </binding>

   <binding>

     <keyPressed code="DELETE" modifiers="mod" />

     <command name="deleteSelectionOrJoinBlockOrDeleteChar"
parameter="keypress" />

   </binding>


works, but it's not acceptable (users will not remember to press
Ctrl/Cmd, they will just press the backspace/del keys to delete stuff).
While the needed:

<binding>

     <keyPressed code="BACK_SPACE" />

     <command name="deleteSelectionOrJoinBlockOrDeleteChar"
parameter="keypress backwards" />

   </binding>

   <binding>

     <keyPressed code="DELETE" />

     <command name="deleteSelectionOrJoinBlockOrDeleteChar"
parameter="keypress" />

   </binding>


does not work (XXE's default deleteSelectionOrJoinBlockOrDeleteChar is
executed instead of the one defined in my customize.xxe file). I'm also
attaching the 0docbook5.xxe file where the relationship between my
custom command and the class implementing it is declared.

I hope the scenario is clear. Thanks in advance for your help!


On Fri, Jan 2, 2015 at 1:27 PM, Hussein Shafie <[email protected]
<mailto:[email protected]>> wrote:

    On 01/02/2015 04:34 PM, Fabián Mandelbaum wrote:


        I'd need to "subvert" the delete action in the following way:

        Whenever a user deletes an element, instead of actually removing
        it from
        the document, an attribute should be set to a specific value on the
        element in question (for example: revisionflag="deleted" on
        DocBook5).

        I've tried to use customize.xxe to bind Ctrl+K to another action
        (tried
        with "alert boo!" command) and it does not work, the element is
        still
        deleted whenever I press Ctrl+K.


    I've added

    ---
    <command name="delete">
       <macro>
         <sequence>
           <command name="alert" parameter="NOT DELETED" />
         </sequence>
       </macro>
    </command>

    <binding>
       <keyPressed code="A" modifiers="mod" />
       <command name="alert" parameter="NOT REPEATED" />
    </binding>
    ---

    to my existing customize.xxe and it works just fine:

    * Ctrl-K (bound to my now custom "delete" command) shows an alert box.
    * My custom Ctrl-A binding also shows an alert box.

    My guess is that you have created customize.xxe by hand (as opposed
    to installing the add-on called "A sample customize.xxe" using
    "Options|Install Add-ons") and forgot to clear the quick start cache.

    See
    
http://www.xmlmind.com/__xmleditor/_distrib/doc/help/__advancedOptions.html#__cacheOptions
    
<http://www.xmlmind.com/xmleditor/_distrib/doc/help/advancedOptions.html#cacheOptions>





        I've searched the docs for action specifiers and I could not
        find any. I
        confess I did not scan the full file set under doc/ folder for XXE
        deployment, but believe me I read LOTS of XXE docs.

        I was wondering if I can redefine the menus and toolbars to
        remove all
        "delete" actions I can find, and then add a "custom delete"
        button that
        will perform the addAttribute command to set the needed
        attribute to the
        wanted value... but supposing I can do that (I'm 99.9% sure I
        can), how
        can I get rid of the default "delete" action so I'm sure the
        user cannot
        use that action inadvertently (or otherwise) in a way that the only
        means to "delete" an element is with my "custom delete" button?


    Your first idea is the right one: simply replace all delete commands
    by a custom delete commands of yours.

    I'm saying *all* delete commands because for example,

    * Ctrl-K is bound to: delete [implicitElement]

    while:

    * Del is bound to: deleteSelectionOrJoinBlockOrDe__leteChar

    You can list all bindings supported by a configuration by opening a
    document and then selecting "Help|Mouse and Key bindings". This menu
    item is present only if you turn on the "Enable the Developer Tools"
    feature. See
    
http://www.xmlmind.com/__xmleditor/_distrib/doc/help/__generalOptions.html#__featuresOptions
    
<http://www.xmlmind.com/xmleditor/_distrib/doc/help/generalOptions.html#featuresOptions>





        I've seen there's some application events defined, but I have
        not seen
        such a thing as a generic "delete" (or "add") application event
        defined.

        Even writing a custom delete command in Java is a viable option,
        provided I can get rid of (or disable somehow, or replace it by
        mine)
        the default XXE "delete" action (menu/toolbar).

        I hope the scenario and constraints are clear.

        I apologize in advance if what I need is explained somewhere in
        the doc,
        and I've happen to have missed that piece of doc.

        Thanks in advance for your precious help!



Attachment: sample_customize_docbook5.tar.gz
Description: GNU Zip compressed data

--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to