How to change cursor image in ExtJS 4.1

混江龙づ霸主 提交于 2020-01-06 02:35:08

问题


In ExtJS 4.0.2a I could change the cursor image over a grid using:

body.setStyle('cursor','move');

This doesn't seem to work in 4.0.7 or 4.1. I don't get any css error but it does give an unnatural lag at the point where the change should occur. Maybe it gets overridden?

UPDATE:

I am trying to run this from a grid onitemmousedown event. I found that the GridView gets a class ".x-unselectable" to make grid text unselectable (which I want). However in ExtJS 4.0.7 and 4.1 this ".x-unselectable" class has a cursor: default setting which gets inherited by all rows and cells of the grid and which overrides any other style attributes I apply to the cursor. It didn't have this in 4.0.2a.

If I force the gridview cursor style using !important the cursor only changes when I get it exactly on top of the 1px line in between two rows because the row still inherits the cursor setting. I suppose I could override the cursor style for all rows and then all cells using this same method but it seems like there should be some cleaner extjs method.


回答1:


Is there any particular reason not to just use CSS?

<style>
.MyTarget{
   cursor: pointer;
}

/*override the panel header cursor */
.x-form-field {
    cursor: pointer;
}
</style>
<div class="MyTarget">The cursor will be a pointer over the body here</div>

// Some Ext to create a panel - the panel header will have the new cursor declared in the CSS



回答2:


I'm guessing body is referring directly to the DOM element for the body. Have you tried

Ext.getBody().setStyle("cursor", "move");

That will wrap the body as an Ext.Element and give you all the nice methods. If that doesn't work, I suggest opening up a debugger and stepping into the setStyle function to see if anything weird is going on, or putting a watch on body.style.cursor.



来源:https://stackoverflow.com/questions/9116097/how-to-change-cursor-image-in-extjs-4-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!