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
最满意答案
看看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.
相关问答
更多-
由贝塞尔曲线绘制路径(Drawing path by Bezier curves)[2024-04-28]
这里有几个可以帮助你的参考资料: 使用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 -
如何绘制用三次贝塞尔曲线绘制的椭圆的部分?(How can I draw parts of an ellipse drawn with cubic bezier curves?)[2022-12-25]
看看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 ... -
Bezier曲线在As3中(Bezier curves in As3)[2023-05-02]
如果您正在使用绘图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 ...