B2016-281 - handle when text is selected (highlighted) and the first keystroke is a dash or backslash. Also handle when dash or backslash is entered between two links such as two ROs that are butt up against each other.
This commit is contained in:
		| @@ -1209,7 +1209,7 @@ namespace Volian.Controls.Library | ||||
| 		} | ||||
| 		private string GetAddSymbolText(string symtxt) | ||||
| 		{ | ||||
| 			 return (@"{\f0\fs" + this.Font.SizeInPoints * 2 + @" " + symtxt + @"}"); | ||||
| 			return (@"{\f1\fs" + this.Font.SizeInPoints * 2 + @" " + symtxt + @"}"); // B2016-281 fixed font selection when inserting a symbol character | ||||
| 		} | ||||
| 		public void AddRtfLink(string linkUrl, string linkValue) | ||||
| 		{ | ||||
| @@ -2525,29 +2525,37 @@ namespace Volian.Controls.Library | ||||
| 				// add the character with its font depending on the char.... | ||||
| 				if (!IsControlChar) | ||||
| 				{ | ||||
| 					if (e.KeyChar >= ' ') | ||||
| 					{ | ||||
| 						// B2016-281  if entered keystroke is a character that converted to a symbol (i.e. dash or backslash) | ||||
| 						//            or if it's a RFT special character (i.e. open and close curly brackets) | ||||
| 						//            then flag it and replace selected text with a null string (removing selected text) | ||||
| 						//            and then insert the symbol or RTF escape codes for those characters | ||||
| 						bool isSymbolOrRTF = e.KeyChar == '-' || e.KeyChar == '\\' || e.KeyChar == '{' || e.KeyChar == '}'; | ||||
| 						LinkLocation ll = FindBetweenLinks(); | ||||
| 						if (ll != null && SelectionLength == 0) // SelectionLength = 0 means insert | ||||
| 						{ | ||||
| 							// replacing between links, this is a special case | ||||
| 							string strpressed = null; | ||||
| 							if (e.KeyChar == '-') | ||||
| 								strpressed = GetAddSymbolText(@"\u8209?"); | ||||
| 							else if (e.KeyChar == '\\') | ||||
| 								strpressed = GetAddSymbolText(@"\u9586?"); | ||||
| 					else | ||||
| 						strpressed = e.KeyChar.ToString(); | ||||
| 					if (e.KeyChar >= ' ') | ||||
| 					{ | ||||
| 						LinkLocation ll = FindBetweenLinks(); | ||||
| 						if (ll != null && SelectionLength == 0) // SelectionLength = 0 means insert | ||||
| 						{ | ||||
| 							if (e.KeyChar == '}') | ||||
| 							else if (e.KeyChar == '}') | ||||
| 								strpressed = @"\}"; | ||||
| 							else if (e.KeyChar == '{') | ||||
| 								strpressed = @"\{"; | ||||
| 							InsertCharBetweenLinks(ll, strpressed); // e.KeyChar); | ||||
| 							else | ||||
| 								strpressed = e.KeyChar.ToString(); | ||||
| 							InsertCharBetweenLinks(ll, strpressed); | ||||
| 							e.Handled = true; | ||||
| 						} | ||||
| 						else if (SelectionLength != 0) | ||||
| 						{ | ||||
| 							HandleDeleteKeyWithSelectedText(new KeyEventArgs(Keys.None), strpressed); | ||||
| 							e.Handled = true; | ||||
| 							// B2016-281 if replacing with a dash, backslash, or curly brackets, first replace with nother (to delete selection) | ||||
| 							//           and set the e.Handled to false so that AddSybol or AddRTF is used to insert that character. | ||||
| 							HandleDeleteKeyWithSelectedText(new KeyEventArgs(Keys.None), isSymbolOrRTF ? "" : e.KeyChar.ToString()); | ||||
| 							e.Handled = !isSymbolOrRTF; | ||||
| 						} | ||||
| 					} | ||||
| 					if (!e.Handled) | ||||
| @@ -2560,7 +2568,6 @@ namespace Volian.Controls.Library | ||||
| 							AddRtf(@"\}"); | ||||
| 						else if (e.KeyChar == '\\') | ||||
| 							AddSymbol(@"\u9586?"); // unicode hex 2572 | ||||
| 							//AddRtf(@"\\"); | ||||
| 						else | ||||
| 							return; | ||||
| 						e.Handled = true; // flag that it's been handled, otherwise, will get 2 chars. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user