Home Forums General XMetaL Discussion content: CSS issue in XMAX 5.5 Reply To: content: CSS issue in XMAX 5.5


Reply to: content: CSS issue in XMAX 5.5

Well, I did find a very hacky workaround for this in XMAX 5.5. This is all driven from a C# .Net WinForms wrapper for the XMAX control (using the interop which is generated when you drop an XMAX control onto a WinForms control).

In the 'PreviewKeyDown' event of the XMAX control I do the following:

[code]private void axXMetaLControl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
            if (e.KeyCode == Keys.Right && !e.Control)
                /* You can't 'right-arrow' the cursor past the final character in an
                * element, if that element happens to be bound by a CSS-specified
                * 'after' image.
                * We have to do some stuff to move the cursor beyond the
                * element and then step it back. The final step of this has to be
                * handled in the UpdateUI event. */

                var startingRange = this.XmaxControl.Document.Range;
                var rangeToPlayWith = startingRange.Duplicate;


                int i = 0;

                while (!rangeToPlayWith.get_IsAdjacent(startingRange))


                    if (i > 2)

                if (i == 2)
                    // CTRL+RIGHT doesn't cause the issue! And at this position
                    // RIGHT has the same effect (or should do!) as CTRL+RIGHT.
                    // So we send a CTRL+RIGHT keypress.

                    // Now the original RIGHT keypress will happen too. This
                    // will need to be corrected in the UpdateUI method
                    // (if we handle it here the original issue will recur).
                    // So we set a global private variable which will be picked up
                    // in UpdateUI…
                    this._movedTooFarRight = true;

Note that I can find no way to stop the original 'Right-arrow' operation from completing in addition to the hacked 'CTRL+Right-arrow'. So I have to set a global boolean which says 'we went too far right' and then check for this this in the 'UpdateUI' event (code not shown for this). If it's true, we step back one cursor position again.

Note also that I have to step beyond the container and then work backwards. I can't 'MoveRight' with the range because the same issue happens then as well (i.e. the range cursor jumps back to the start of the element).

The only issue with this (other than I'm chucking state around between events which makes me uncomfortable) is it is really slow and causes a noticeable lack when using the 'right-arrow' key. I'm wondering if there are any more efficient ways to work out where the cursor position is within the Element.