ScintillaNET icon indicating copy to clipboard operation
ScintillaNET copied to clipboard

ReadOnly Mode Visual Studio Properties Panel Issue

Open Chadt54 opened this issue 4 years ago • 2 comments

In Visual Studio, in the Properties Panel for the control, if you have the ReadOnly mode set to True, then you can't change or set the "Text" property in the Properties panel.

Chadt54 avatar Apr 03 '21 06:04 Chadt54

Changind the Scintilla Text property setter from this:

  set
  {
      if (string.IsNullOrEmpty(value))
      {
          DirectMessage(NativeMethods.SCI_CLEARALL);
      }
      else if (value.Contains("\0"))
      {
          DirectMessage(NativeMethods.SCI_CLEARALL);
          AppendText(value);
      }
      else
      {
          fixed (byte* bp = Helpers.GetBytes(value, Encoding, zeroTerminated: true)) 
              DirectMessage(NativeMethods.SCI_SETTEXT, IntPtr.Zero, new IntPtr(bp));
      }
  }

into this:

  set
  {
      var previousReadOnly = DesignMode ? ReadOnly : false;

      // Allow Text property change in read-only mode when  designer is active.
      if (previousReadOnly && DesignMode)
      {
          DirectMessage(NativeMethods.SCI_SETREADONLY, IntPtr.Zero);
      }

      if (string.IsNullOrEmpty(value))
      {
          DirectMessage(NativeMethods.SCI_CLEARALL);
      }
      else if (value.Contains("\0"))
      {
          DirectMessage(NativeMethods.SCI_CLEARALL);
          AppendText(value);
      }
      else
      {
          fixed (byte* bp = Helpers.GetBytes(value, Encoding, zeroTerminated: true)) 
              DirectMessage(NativeMethods.SCI_SETTEXT, IntPtr.Zero, new IntPtr(bp));
      }

      // Allow Text property change in read-only mode when  designer is active.
      if (previousReadOnly && DesignMode)
      {
          DirectMessage(NativeMethods.SCI_SETREADONLY, new IntPtr(1));
      }
  }

I can only make the change to my own fork as a PR is on the way and the official doesn't currently seem to be in active development.

VPKSoft avatar Apr 03 '21 08:04 VPKSoft

Wow! Fast turn around! Thank you!

Currently, I'm ok with dealing with the workaround of disabling the readonly mode for a quick second to edit the text property, but just wanted to post the issue to here to make sure the bug is known and can be fixed in the future (but it got fixed immediately! haha).

So, glad I could help! and thanks again for the fast turn around :)

Chadt54 avatar Apr 03 '21 15:04 Chadt54