Home Search Member List Faq Register Login  
UltimateSpell
Re: Spellcheck textbox focus issues on modal windows.

Thread Starter: samir   Started: 12-26-2013 12:44 PM   Replies: 3
 Karamasoft Support Forums » General Discussions » UltimateSpell » Re: Spellcheck textbox focus issues on modal windows.
 Printable Version    « Previous Thread   Next Thread »
  26 Dec 2013, 12:44 PM
samir is not online. Last active: 12/26/2013 12:47:25 PM samir

Not Ranked
Joined on 12-26-2013
Posts 1
Spellcheck textbox focus issues on modal windows.
Hi

We are using UltimateSpell v3.7SP4 and are running into some weird focus issues when working with modal windows.

We have our own server control for creating the spellcheck text box.
When this server control is used on a modal window (launched using the window.showModalDialog) for some reason the window loads with keyboard focus (caret) already in the spellcheck textbox when it should not be. And even more strange, when we mouse click onto the textbox the caret just disappears. Now if you start typing, nothing happens Sad. but if we press tab the caret reappears in the spellcheck textbox and then users can type into the control. But again, if we click the mouse over the control the caret is again lost!!


I have this isolated down to a standalone aspx page and a stripped down version of our server control but am not sure how I can upload that with this post.

So here's some basic information:

The modal window is launched using the javascript below on the main page:

< Input type="button" runat="server" id="lauchnew" onclick="launchpopup()" value="launch new popup"/>

function launchpopup() {
window.showModalDialog("spellcheck2.aspx", "myWindow", "status = 1, height = 300, width = 300, resizable = 0")
}
----------------------------------------------------

The modal window contains the following markup

< mycontrols : SpellCheckTextBox ID="buFY_Budget_History__Adjustment_Comments_Narr" runat="server" />
---------------------------------------------------

The server control code is as below

public class SpellCheckTextBox : TextBox
{


private UltimateSpell ultimateSpellControl;


/// The ID of the primary spell check control on the page
public const string SpellCheckControlId = "SpellCheckControl";


#region Properties

[Bindable(true)]
[Category("SpellChecker")]
[DefaultValue(true)]
[Localizable(true)]
[Description("Highlight misspelled words as you type.")]
public bool SpellAsYouType
{
get
{
EnsureChildControls();
return (ultimateSpellControl.SpellAsYouType);
}

set
{
EnsureChildControls();
ultimateSpellControl.SpellAsYouType = value;
}
}

#endregion

#region Overrides

/// <summary>
/// Creates an instance of the spellcheck control and adds it to the Controls collection of this control
/// </summary>
protected override void CreateChildControls()
{
Controls.Clear();

ultimateSpellControl = new UltimateSpell();
ultimateSpellControl.ID = string.Format("{0}{1}", SpellCheckControlId, ClientID);

ultimateSpellControl.ControlIdsToCheck = base.ClientID;

ultimateSpellControl.SpellButton.ID = string.Format("{0}{1}", ultimateSpellControl.ID, "Button");
ultimateSpellControl.SpellButton.ButtonType = SpellButtonType.LinkButton;
ultimateSpellControl.SpellButton.CssClass = "SpellcheckButton";
ultimateSpellControl.SpellButton.Text = "Check Spelling";

ultimateSpellControl.IncludeDirectory = "/SpellCheck/";
ultimateSpellControl.CustomDictionary = "/SpellCheck/";

ultimateSpellControl.ShowAddButton = false;
ultimateSpellControl.ShowSpellButton = false;

//Last character being removed when mouse clicking out of spellcheck field
//Per http://forums.karamasoft.com/ShowPost.aspx?PostID=8816 this is required to fix the problem.
ultimateSpellControl.AutoEventWireup = false;

//Add the control to this CONTROL'S controls collection
this.Controls.Add(ultimateSpellControl);

ChildControlsCreated = true;
}


/// <summary>
/// Finds an existing spellcheck control and add it to the pageItems
/// </summary>
/// <param name="pArgs"></param>
protected override void OnPreRender(EventArgs pArgs)
{
if (this.Page.Items[SpellCheckControlId] == null)
{
//Remove any previous instance of the spellcheck control on the page.
Controls.Remove(ultimateSpellControl);

// Add a nw instanc to the pageitems
ultimateSpellControl.ID = SpellCheckControlId;
SpellAsYouType = true;
Controls.Add(ultimateSpellControl);
Page.Items.Add(SpellCheckControlId, ultimateSpellControl);
}


base.OnPreRender(pArgs);
}

/// <summary>
/// Renders this textbox control and the spellcheck to the page
/// </summary>
/// <param name="pWriter"></param>
protected override void Render(HtmlTextWriter pWriter)
{

TextMode = TextBoxMode.MultiLine;

//Render the textbox
base.Render(pWriter);

//Get a reference to the primary spellchecker
ultimateSpellControl = (UltimateSpell)this.Page.Items[SpellCheckControlId];

if (ultimateSpellControl != null)
{
//Render the spellchecker
ultimateSpellControl.RenderControl(pWriter);

//Cleanup the temporary Page.Items
this.Page.Items[SpellCheckControlId] = null;
}
}

#endregion
}
----------------------------------------------------


fwiw, removing the <b> 'ultimateSpellControl.AutoEventWireup = false;' </b> line from the server control code fixes this issue but then it causes the issue for which this line has been added - that the last character typed into the edit control is deleted when the user clicks outside the control.

Hope you can let us know why we are seeing this issue and a fix as well Smile

  
  26 Dec 2013, 2:14 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Spellcheck textbox focus issues on modal windows.
AutoEventWireUp shouldn't normally cause an issue unless your page has some client-side script in it. Do you have any client-side script in your popup?
  
  15 May 2014, 8:28 AM
kdr is not online. Last active: 5/15/2014 8:39:45 AM kdr

Not Ranked
Joined on 05-15-2014
Posts 1
Re: Spellcheck textbox focus issues on modal windows.
We have the same issue. When Spellcheck is used in regular window, it works fine. When used in a modal, the focus shifts to Spell Check box on load of modal.

Is there any patch for this?

  
  15 May 2014, 11:52 AM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Spellcheck textbox focus issues on modal windows.
It sounds like you enabled the SpellAsYouType feature and it checked the spelling inside the text area when the page is loaded and focused inside the textbox to display the spelling errors. If you want to prevent this behavior, you can set a timer in your dialog page's load event to shift the focus to some other page element after the SpellAsYouType feature has done its spell checking.
  
 Page 1 of 1 (4 items)
Karamasoft Support Forums » General Discussions » UltimateSpell » Re: Spellcheck textbox focus issues on modal windows.

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2018 Karamasoft LLC. All rights reserved.