Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2007-09-12 00:35:54

tissatussa
New member
From: Holland
Registered: 2007-04-05
Posts: 4

focus editor after display : trouble solved

Hi all,

I had some serious trouble focussing Xinha editors which are in hidden div layers.  After days of searching for a solution, I found a simple one, and I want to share it with you.

I use the newest version (v0931, but other versions had this trouble too) and the problem was especially with IE6 (IE7 I did not test) -- in FireFox everything is working fine without the hack I found. The editors are initialised correctly, but after that I hide them. When showing an editor again (display:block / none) it could not receive focus in all situations. I tried several (javascript) constructs but at last I managed to get things working in IE :

xinha_editors[*id*].sizeEditor(4 params);

This makes the editor "wake up" and you can start typing because it receives focus again.


BTW. I found out that the config constructs while initialising (e.g. xinha_editors[*id*].config.height = ...) which are mentioned many times on this forum, are only for setting properties while initialising, you can not use them after that to change the properties of an Editor (... but please correct me if I'm wrong).

This method I found at ...
http://xinha.raimundmeyer.de/JSdoc/Xinh … Xinha.html
... a nice list which contains several other "secret" methods / functions ...!

Here you can read about the "sizeEditor" method :

-------------------
void sizeEditor(<string> width, <string> height, <Boolean> includingBars, <Boolean> includingPanels)

Size the editor to a specific size, or just refresh the size (when window resizes for example)

Parameters:
  width - optional width (CSS specification)
  height - optional height (CSS specification)
  includingBars - optional to indicate if the size should include or exclude tool & status bars
  includingPanels - optional to indicate if the size should include or exclude panels
-------------------


HTH,
Roelof


simple is not always best, but best is always simple

Offline

#2 2007-09-17 11:55:18

Practicality
Xinha Community Member
Registered: 2007-02-15
Posts: 24

Re: focus editor after display : trouble solved

Interesting. I ran into a similar problem, and actually got around it by removing/re-adding hidden editors (didn't have time to research this solution). When adding a new editor, I have found that the following construct works well:

        xinha_editorsnew = Array();
        xinha_editorsnew.push('txtNormal', 'txtSuccess' , 'txtFailure');
        xinha_editorsnew   = Xinha.makeEditors(xinha_editorsnew, xinha_config, xinha_plugins);
        Xinha.startEditors(xinha_editorsnew);
        xinha_init();

However, I don't think we should have to refocus a hidden editor. I wonder if there is a related ticket already...

Offline

#3 2007-09-20 12:45:11

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: focus editor after display : trouble solved

deactivateEditor and activateEditor are your friends here in lots of cases.  Essentially you should deactivate before changing anythng regarding the style of the editor (especially visibility, even if it's "inheritied") and reacivate it after. 

Xinha should also be visible at least when it is created, otherwise sizing will probably be messed up.


James Sleeman

Offline

#4 2007-09-21 04:44:40

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: focus editor after display : trouble solved

You may use visibility:hidden during creation when you want the editor not to be seen. Once it's ready you may do deactivateEditor() and  display:none

Offline

#5 2007-09-28 20:05:33

tissatussa
New member
From: Holland
Registered: 2007-04-05
Posts: 4

Re: focus editor after display : trouble solved

I did not mention it, but I knew about these 'basics" ..

gogo wrote:

deactivateEditor and activateEditor are your friends here in lots of cases.  Essentially you should deactivate before changing anythng regarding the style of the editor (especially visibility, even if it's "inheritied") and reacivate it after. 

Xinha should also be visible at least when it is created, otherwise sizing will probably be messed up.

ray wrote:

You may use visibility:hidden during creation when you want the editor not to be seen. Once it's ready you may do deactivateEditor() and  display:none

.. because I first read your forum for possible solutions. Nevertheless, I ran into the situation of this topic, and my solution is as I described.  When anyone has the same problem, maybe my solution helps, but it is possible some other programming issue in my project made me have to use the solution I described, I don't know.    Thanks anyway for completing this issue.


simple is not always best, but best is always simple

Offline

Board footer

Powered by FluxBB