标签: highlight

JavaScript:从页面中删除当前鼠标突出显示?

假设我使用鼠标在页面上突出显示一些文字.如何使用JavaScript删除所有突出显示的文本?

谢谢.

javascript select highlight

11
推荐指数
1
解决办法
1万
查看次数

如何在iOS SDK中禁用UIView/UIViewController的"突出显示子视图"消息?

我想在UITableViewCell点击它时使用默认突出显示.但是,我不希望自定义子视图(及其子视图)接收消息以更新其突出显示的状态,从而破坏backgroundColor属性.

编辑
"子视图"我指的是任何子UIView类,而不仅仅是UITableViewCells.

也许这种假设的情况会更好地表达我正在寻找的东西:我有一个UITableViewCell.叫它c.然后我添加一个UIView(称之为v)作为c的子视图.当我点击c时,我想要c突出显示(标准蓝色背景,白色字体颜色),但我不希望v突出显示.我该如何实现这一目标?

highlight background-color uiview ios subviews

11
推荐指数
2
解决办法
5407
查看次数

Android:将列表视图项设置为"已选中"(突出显示)

在我的应用程序中,我想要在平板电脑上执行类似于gmail应用程序的操作,在左侧有项目列表,在右边有一个包含该项目内容的片段,就像gmail app一样,这些内容在选择后正在下载.点击一个项目后,我希望它保持高亮显示,直到我改变选择.我达到了这个有效的点,但只有当我在同一个项目上点击两次时,所以首先我点击,选择工作,然后项目回到'默认'状态,如果我再次点击它,选择器(选择)状态)是可见的.

这是我到目前为止:

1)选择器(listitem_background.xml)

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/solid_white" android:state_pressed="false" android:state_selected="false"/>
    <item android:drawable="@drawable/listitem_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/listitem_focused" android:state_selected="true"/>

</selector>
Run Code Online (Sandbox Code Playgroud)

2)对于列表项的顶部线性布局:

android:background="@drawable/listitem_background"
Run Code Online (Sandbox Code Playgroud)

(我尝试将其设置为listselector,以及)

3)这是ListView:

<ListView
    android:id="@+id/my_list_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:choiceMode="singleChoice"
    android:dividerHeight="1dp"
    android:drawSelectorOnTop="true"
    android:fadeScrollbars="true"
    android:fastScrollEnabled="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:scrollbarFadeDuration="100"
    android:scrollbars="vertical" />
Run Code Online (Sandbox Code Playgroud)

4)在代码部分我试着用这个:

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    view.setSelected(true);
    ...
}
Run Code Online (Sandbox Code Playgroud)

[编辑]实际上我注意到在屏幕右侧提交片段后选择丢失了.如果我不提交片段,它就像魅力......我想我在选择器中需要这样的东西:

<item android:drawable="@drawable/listitem_focused" android:state_activated="true" android:state_focused="false"/>
Run Code Online (Sandbox Code Playgroud)

但显然不是这个......

android listview highlight selector

11
推荐指数
1
解决办法
3万
查看次数

D3突出显示所选节点,并将其链接到强制有向图中的父节点和祖先节点

我想在子节点悬停时突出显示图中父节点的链接和节点.我从纽约时报的"白宫之路"中汲取灵感:

在此输入图像描述

我用这个小提琴看到了这个问题的答案:

var node = svg.selectAll(".node")
    .data(graph.nodes)
   .enter()
    .append("g")
    .attr("class", function(d) { return "node " + d.name + " " + d.location; })
    .call(force.drag)
    .on("mouseover", function(d) { 
        // if(isConnected(d, o)) {
        d3.select(this).select("circle").style("stroke-width", 6);               
        var nodeNeighbors = graph.links.filter(function(link) {
            return link.source.index === d.index || link.target.index === d.index;
        })
        .map(function(link) {
             return link.source.index === d.index ? link.target.index : link.source.index;
        });               
        svg.selectAll('circle').style('stroke', 'gray');
        svg.selectAll('circle').filter(function(node) {
            return nodeNeighbors.indexOf(node.index) > -1;
        })
        // }
    .on("mouseover", function(d) { 
        //   I …
Run Code Online (Sandbox Code Playgroud)

parent highlight hover d3.js force-layout

11
推荐指数
1
解决办法
9481
查看次数

Vim变量语法高亮显示

我想更改我的vim配置文件,以便只突出显示我声明的变量,而不是关键字.本文展示并解释了我的意思:替代语法突出显示

我是vim的初学者(我从未更改过默认的配置文件).有人能指出我正确的方向吗?

syntax vim syntax-highlighting highlight vim-syntax-highlighting

11
推荐指数
1
解决办法
5353
查看次数

Pandas样式功能可以突出特定列

我一直在尝试编写一个与pandas风格一起使用的函数.我想要在参数中指定的高列.这不是很优雅,但例如:

data =  pd.DataFrame(np.random.randn(5, 3), columns=list('ABC'))

def highlight_cols(df, cols, colcolor = 'gray'):
    for col in cols:
        for dfcol in df.columns:
            if col == cols:
                color = colcolor
    return ['background-color: %s' % color]*df.shape[0]
Run Code Online (Sandbox Code Playgroud)

然后打电话:

data.style.apply(highlight_cols(cols=['B','C']))
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:("'系列'对象没有属性'列'")

我认为我从根本上不太明白样式器如何调用和应用该函数.

谢谢,

python styles highlight pandas

11
推荐指数
2
解决办法
2万
查看次数

根据textContent中的索引突出显示文本

赏金

正如jsPerf所展示的那样,赏金将在测试时通过最新版本的Firefox,Chrome和Internet Explorer获得最快的解决方案,或者在我自行决定创建此类解决方案最有用的答案.Mwahahaha!

我将主要满足的是通吃的溶液偏移 S和未处理<span>,并添加突出显示的是,让parent.textContent = parent.textContent后面运行的偏移将重新的更新列表上的解决方案的亮点,但这不利的时间复杂度所以不是首选.


相关问题


我有一个只包含文本的元素,我想强调一下.我也有一个数组[startline, startcol, endline, endcol],知道每行的长度.textContent,我可以标准化为[startoffset, endoffset].如何在每对偏移 s 之间突出显示

这个问题比看起来更难,因为:

  • 内容不保证没有重复(所以没有查找/替换),和
  • 必须最终对已经突出显示的文本执行突出显示,有时与已突出显示的文本相交,并且
  • 必须根据父元素.textContent属性的索引执行突出显示.

定义

  • 亮点:放置文本的子集从一个元素的textContent一个或多个<span class="highlighted">而不改变父元素的textContent值,即突出显示的n倍为n嵌套内,使得文本<span class="highlighted">元素.
  • offset:一个非负整数,表示某个点之前的字符数(在两个字符之间).
  • character:一个JavaScript给你的实例,作为.textContent字符串给定索引(包括空格)的值.

MCVE

function highlight(parent, startoff, endoff) {
  // …
Run Code Online (Sandbox Code Playgroud)

javascript text dom highlight offset

11
推荐指数
1
解决办法
760
查看次数

C#ListView详细信息,突出显示单个单元格

我在C#中使用ListView来制作网格.我想找到一种能够以编程方式突出显示特定单元格的方法.我只需要突出显示一个单元格.

我已尝试使用所有者绘制的子项目,但使用下面的代码,我得到突出显示的单元格,但没有文字!有关于如何使其工作的任何想法?谢谢你的帮助.

//m_PC.Location is the X,Y coordinates of the highlighted cell.


void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
    if ((e.ItemIndex == m_PC.Location.Y) && (e.Item.SubItems.IndexOf(e.SubItem) == m_PC.Location.X))
        e.SubItem.BackColor = Color.Blue;
    else
        e.SubItem.BackColor = Color.White;
    e.DrawBackground();
    e.DrawText();
}
Run Code Online (Sandbox Code Playgroud)

c# listview highlight ownerdrawn

10
推荐指数
1
解决办法
3万
查看次数

ListView保持选中状态?

我有一个包含项目的列表视图,在用户选择一个项目点亮后,它会恢复正常.有没有办法让它在用户选择ListView中的项目时保持选中状态并突出显示?

android listview highlight

10
推荐指数
1
解决办法
2万
查看次数

在textarea中突出显示.js

所以我一直在文本区域使用highlight.js,因为显然这不起作用:

<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
<link rel="stylesheet" href="styles/default.css">
<script src="highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<form>
    JavaScript Injection: <br> 
<pre>
<code>
<textarea name="js_execute" cols="50" rows="10" "></textarea>
</code>
</pre>
<input type="button" name="Inject_Execute_Button" value = "Inject" onclick="executeJS()" >
</form>

<script type="text/javascript">
 function executeJS()
 {
     alert("Wohoo");
 }
</script>


<style type ="text/css">

</style>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我很确定这是一个简单的答案,所以我不会详细解释它,但最后我更愿意将代码输入到用JavaScript突出显示的textarea中.

html javascript syntax-highlighting highlight highlight.js

10
推荐指数
3
解决办法
2万
查看次数