MyBB Community Forums

Full Version: Turn off cursor focus in SCEditor?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Its annoying when the page jumps to the last box with an editor (especially in the ModCP when you go to edit a profile, it just goes straight to signature box at the bottom).

Is there a way to turn this off?

Update tried to follow this information and added this to codebuttons under MyBBEditor = $("#{$bind}").sceditor("instance");:
 sceditor("instance").focus(false)

No luck, I am doing something wrong
Thanks. This bothers me too.
(2023-02-25, 10:29 PM)Taylor M Wrote: [ -> ]Update tried to follow this information and added this to codebuttons under MyBBEditor = $("#{$bind}").sceditor("instance");:
 sceditor("instance").focus(false)

No luck, I am doing something wrong

That's a callback function on focus. Try the autofocus option when the editor is initiated: https://www.sceditor.com/documentation/options/

Says it defaults to false and it doesn't seem to be being set to true anywhere, but maybe we have an older version where it's true by default and needs to be set to false.
(2023-02-26, 03:39 PM)Matt Wrote: [ -> ]That's a callback function on focus. Try the autofocus option when the editor is initiated: https://www.sceditor.com/documentation/options/

I saw this but I really just don't know how to implement it. I'm pretty decent and working through php and figuring out smaller things but javascript is 110% foreign to me and that documentation site is very limited on examples or how to do something specifically.

(2023-02-26, 03:39 PM)Matt Wrote: [ -> ]Says it defaults to false and it doesn't seem to be being set to true anywhere, but maybe we have an older version where it's true by default and needs to be set to false.

I'm running the latest version of MyBB, this happens on literally every MyBB site i've been on including this one. So I'm really not sure.



I did attempt this in codebuttons template under autoUpdate: true,
autofocus: false,

Doesn't work though.
Just a friendly bump to see if anyone else has any ideas.
Sorry to necro, but I was also getting annoyed by this and couldn't dig up any existing solutions. But I did find this thread. I wanted a purely front-end fix, so what I did was

1) changed the container div id (#signature) to something else, so the built-in script to load the sceditor couldn't find its target.
2) added a new event listener to load the sceditor only when the text box was clicked into.

It's hacky, but the page no longer jumps halfway down on load.
I hope it is okay to double necro, but the solution I came to was adding the following code from theĀ SCEditor official website. This made the autoFocus option work and so far I have not had any conflicts or issues.


<script src="https://cdn.jsdelivr.net/npm/sceditor@3/minified/sceditor.min.js"></script>

The following can be found inĀ Ungrouped Templates -> codebuttons

You have to place it after the initial jquery.sceditor.bbcode.min.js but before plugins/undo.js like below:
<link rel="stylesheet" href="{$mybb->asset_url}/jscripts/sceditor/themes/{$theme['editortheme']}" type="text/css" media="all" />
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/sceditor/jquery.sceditor.bbcode.min.js?ver=1832"></script>
<script src="https://cdn.jsdelivr.net/npm/sceditor@3/minified/sceditor.min.js"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/bbcodes_sceditor.js?ver=1837"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/sceditor/plugins/undo.js?ver=1832"></script>
<script type="text/javascript">
var partialmode = {$mybb->settings['partialmode']},

Then add the following to the opt_editor. I placed mine after the autoUpdate: true, line.
autoFocus: false,
@kohana This works, thank you!