有没有办法停止从文本区域复制文本?我尝试通过以下代码禁用从简单文本区域复制,但我希望这个限制在tinymce文本区域,我不是在谈论按钮我在谈论文本区域写的文本
<textarea id="mytinymcetextarea" class="noselect">Not copy able</textarea>
tinymce.init({
selector: "#mytextarea"
});
$('#mytinymcetextarea').bind('copy',function(e) {
e.preventDefault(); return false;
});
我也尝试过css
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}
如果不可能,还有其他文本编辑器允许禁用复制文本。
答案 0 :(得分:1)
您可以尝试拦截sf::RectangleShape Rect[RECT];
sf::RectangleShape AABB[RECT];
Rect[0].setSize(sf::Vector2f(50.0f, 50.0f));
Rect[1].setSize(sf::Vector2f(50.0f, 100.0f));
Rect[2].setSize(sf::Vector2f(60.0f, 80.0f));
Rect[3].setSize(sf::Vector2f(100.0f, 60.0f));
Rect[4].setSize(sf::Vector2f(30.0f, 250.0f));
AABB[0].setSize(sf::Vector2f(50.0f, 50.0f));
AABB[1].setSize(sf::Vector2f(50.0f, 100.0f));
AABB[2].setSize(sf::Vector2f(60.0f, 80.0f));
AABB[3].setSize(sf::Vector2f(100.0f, 60.0f));
AABB[4].setSize(sf::Vector2f(30.0f, 250.0f));
for (int x = 0; x < RECT; x++)
{
//Starting Position
Rect[x].setOrigin(Rect[x].getSize().x / 2, Rect[x].getSize().y / 2);
AABB[x].setOrigin(AABB[x].getSize().x / 2, AABB[x].getSize().y / 2);
xpos += 150;
Rect[x].setPosition(xpos, ypos);
AABB[x].setPosition(xpos, ypos);
colcount++;
if (colcount == 3)
{
xpos = 0;
ypos += 200;
colcount = 0;
}
Rect[x].setFillColor(sf::Color::Red);
AABB[x].setFillColor(sf::Color::Transparent);
AABB[x].setOutlineThickness(1);
}
while (window.isOpen())
{
window.clear(sf::Color::Black);
//Drawing Shapes
for (int x = 0; x < RECT; x++)
{
window.draw(Rect[x]);
window.draw(AABB[x]);
}
Rect[0].rotate(90 * 3.14 / 180);
Rect[1].rotate(45 * 3.14 / 180);
Rect[2].rotate(10 * 3.14 / 180);
Rect[3].rotate(180 * 3.14 / 180);
Rect[4].rotate(22.5);
for (int i = 0; i < RECT; i++)
{
MinPoint[i].x = Rect[i].getPosition().x - (Rect[i].getSize().x / 2);
MaxPoint[i].x = Rect[i].getPosition().x + (Rect[i].getSize().x / 2);
MinPoint[i].y = Rect[i].getPosition().y - (Rect[i].getSize().y / 2);
MaxPoint[i].y = Rect[i].getPosition().y + (Rect[i].getSize().y / 2);
AABB[i].setSize(sf::Vector2f(Rect[i].getGlobalBounds().width, Rect[i].getGlobalBounds().height));
}
事件并禁用其默认行为:
copy
不能保证这适用于所有浏览器。
除此之外,您还可以删除上下文菜单(请参阅:Remove the Context Menu in TinyMCE),还可以从TinyMCE的“编辑”菜单中删除“复制”选项(请参阅:http://codeasp.net/blogs/microsoft-net/204/tinymce-how-to-remove-cut-copy-and-paste-items-in-edit-menu )。