首页 \ 问答 \ HTMLEditor将光标聚焦在textarea中(HTMLEditor focus cursor inside textarea)

HTMLEditor将光标聚焦在textarea中(HTMLEditor focus cursor inside textarea)

我有一个简单的面板,里面有HTML编辑器。

我只想将光标聚焦在组件的textarea中。
我试图将它集中在afterrender上,将组件默认设置为焦点,但我无法使其工作。

这是我的代码,我该怎么办? 是否有可能将此textarea设置为焦点?

Ext.define('MyApp.view.MyViewport', {
    extend: 'Ext.container.Viewport',
    alias: 'widget.myviewport',

    requires: [
        'MyApp.view.MyViewportViewModel',
        'Ext.panel.Panel',
        'Ext.form.field.HtmlEditor'
    ],

    viewModel: {
        type: 'myviewport'
    },
    layout: 'fit',

    items: [
        {
            xtype: 'panel',
            layout: 'fit',
            title: 'My Panel',
            items: [
                {
                    xtype: 'htmleditor',
                    height: 150,
                    id: 'myEditor',
                    fieldLabel: 'Label'
                }
            ]
        }
    ]

});

也试过这个

{
   xtype: 'htmleditor',
   height: 150,
   id: 'myEditor',
   fieldLabel: 'Label',
   listeners: {
       afterrender: 'onMyEditorAfterRender'
   }
}



Ext.define('MyApp.view.MyViewportViewController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.myviewport',

    onMyEditorAfterRender: function(component, eOpts) {
        component.focus();
    }

});

问题似乎是我正在使用的浏览器,第二个代码适用于Firefox,但不适用于chrome和edge


I've a simple panel with an HTML Editor inside it.

I only want to focus my cursor inside the textarea of the component.
I've tried to focus it on afterrender, to set the component default focused, but I can't make it work.

this my code, what should i do? are there possibilities to set this textarea on focus?

Ext.define('MyApp.view.MyViewport', {
    extend: 'Ext.container.Viewport',
    alias: 'widget.myviewport',

    requires: [
        'MyApp.view.MyViewportViewModel',
        'Ext.panel.Panel',
        'Ext.form.field.HtmlEditor'
    ],

    viewModel: {
        type: 'myviewport'
    },
    layout: 'fit',

    items: [
        {
            xtype: 'panel',
            layout: 'fit',
            title: 'My Panel',
            items: [
                {
                    xtype: 'htmleditor',
                    height: 150,
                    id: 'myEditor',
                    fieldLabel: 'Label'
                }
            ]
        }
    ]

});

Also tryed with this

{
   xtype: 'htmleditor',
   height: 150,
   id: 'myEditor',
   fieldLabel: 'Label',
   listeners: {
       afterrender: 'onMyEditorAfterRender'
   }
}



Ext.define('MyApp.view.MyViewportViewController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.myviewport',

    onMyEditorAfterRender: function(component, eOpts) {
        component.focus();
    }

});

The problem seems to be on the browser i'm using, the second code works on firefox but not on chrome and edge


原文:https://stackoverflow.com/questions/35743758
更新时间:2023-05-14 19:05

最满意答案

看看http://pomax.github.io/bezierinfo/#circles_cubic-它讨论了圆弧的这个问题(控制点值以圆弧角度表示在该部分的底部),但这两者之间的唯一区别和椭圆是其中一个维度的旋转+缩放。 如果你理解圆形近似,你也可以得到椭圆近似。


I've got an simplest way to do it. I just draw, in my Web application, an ellipse using Bezier cuvers. Then, I get the centerX, centerY, width and height of the ellipse and pass them to my android application.

In my Android app, I can draw the ellipse drawn in Web using the drawOval method. With this, I can draw Arcs of the ellipse, using drawArcs method, which receives an Oval as parameter.

相关问答

更多
  • 这里有几个可以帮助你的参考资料: 使用Bezier基元在2D点中绘制平滑曲线 曲线拟合 线平滑和点除草 Here is few references which can help you: Draw a Smooth Curve through a Set of 2D Points with Bezier Primitives Curve fitting Line Smoothing and point-weeding
  • 看看http://pomax.github.io/bezierinfo/#circles_cubic-它讨论了圆弧的这个问题(控制点值以圆弧角度表示在该部分的底部),但这两者之间的唯一区别和椭圆是其中一个维度的旋转+缩放。 如果你理解圆形近似,你也可以得到椭圆近似。 I've got an simplest way to do it. I just draw, in my Web application, an ellipse using Bezier cuvers. Then, I get the cen ...
  • 如果您正在使用绘图API,那么您只能使用curveTo()函数绘制二次贝塞尔曲线。 http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html#curveTo () 对于正确的贝塞尔曲线,它并不难,但你必须自己做。 我找到的一些源代码快速链接: http : //www.paultondeur.com/2008/03/09/drawing-a-cubic-bezier-curve ...
  • 使用Qt Quick 2,您可以使用Canvas项目在2D中绘图(类似于HTML 5画布)。 见http://qt-project.org/doc/qt-5/qml-qtquick-context2d.html#bezierCurveTo-method With Qt Quick 2, you can use Canvas item to drawing in 2D (similar to HTML 5 canvas). See http://qt-project.org/doc/qt-5/qml-qtqu ...
  • 正如cmaster所说,这导致五次多项式的求解以找到六次多项式的最小值 它是2D还是3D并不重要。 最小化的函数是六次多项式 f(t)=0.5*dot(p(t)-X,p(t)-X) such that 0<=t<=1 其中X是给定点,p(t)是多项式曲线, dot表示欧几里得标量积。 通过找到导数的所有根来实现最小化 f'(t)=dot(p'(t), p(t)-X) 在区间内并比较根的功能值和区间的终点。 还存在不使用导数的最小化方法,主要用于比多项式更复杂的函数。 例如参见第5章 Brent,RP(1 ...
  • 如果要解决一般问题,可以使用levenberg-marquardt( LM )优化。 您想要定义具有少量点的贝塞尔曲线。 您可以使用LM通过最小化所有点的曲线平方距离来优化曲线参数(点位置)。 这是你的目标函数 ,即平方距离的总和。 诀窍在于计算LM的梯度和粗糙度。 你可以用数字方式做到这一点,而无需计算任何数学。 使用数值微分来计算用于查找渐变的雅可比(J)。 (Jacobian也被LM用来近似Hessian。) Matti提到GSL用于平滑样条曲线。 我不知道GSL,但事实证明它有LM和数值差异的实现。 ...
  • 还有一点非常重要,那就是您使用大量固定长度的直线段逼近曲线。 这在曲线几乎笔直的区域是低效的,并且可能导致曲线非常弯曲的令人讨厌的角度折线。 没有一个简单的折衷方案可以用于高曲率和低曲率。 为了解决这个问题,您可以动态细分曲线(例如,在中间点将其分成两部分,然后查看两条线段是否在曲线的合理距离内。如果一个线段非常适合于曲线,停在那里;如果不是,则以相同的方式细分并重复)。 您必须小心细分它,以便在以这种方式采样曲线时不会错过任何局部(小)特征。 这并不总能使您的曲线“更快”,但它将保证在使用实现该质量所需的 ...
  • 这篇优秀的CodeProject文章描述了如何从第一原理生成Bezier曲线。 在提问之后,他偶然发现了这篇文章。 This excellent CodeProject article describes how to generate the Bezier curves from first principles. Stumbled upon the article some time after asking the question.
  • 注意: Flash Player 11以后包括绘制三次曲线的本机方法cubicBurveTo() ,如果您的目标是FP11,它应该是最快的方法。 就在上周,我写了一个类来绘制任意顺序的Bezier曲线。 代码没有优化,但在我的测试中工作正常。 性能是可接受的动画事件(虽然我不认为滥用它是一个好主意,因为我说它没有优化;当然,将它们用于二次曲线是没有意义的,因为玩家可以这本地做)。 如果你想使用它或看看代码在这里: BezierCurve课程 示例代码 我认为使用示例代码,您将能够毫无困难地弄清楚如何使用它( ...
  • 想象一下B点和E点之间的三次曲线。 如果将其定义为具有张力参数s的基数样条,则这些点中的切向量为 T b = s *( E - A ) T e = s *( F - B ) 如果曲线定义为贝塞尔曲线,则切线矢量为 T b = 3 *( C - B ) T e = 3 *( E - D ) 如果曲线BE相同,则切线的值相等,如果已知A,B,E,F,s,我们可以找到Bezier的控制点。 反之亦然 - 如果B,C,D,E,s已知,我们可以找到基数样条的A,F点。 例如,Bezier的第一个控制点是 C = B ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)