Assigning different behaviors on click & doubleClick

本文探讨了在Flex应用程序中如何正确处理DataGrid的单击与双击事件,通过使用计时器来区分这两种操作,并避免事件冲突。

http://raghuonflex.wordpress.com/2007/08/10/assigning-different-behaviors-on-click-doubleclick/

 

 

This interesting issue was posted by Arpan on the flex_india group (Read it here). He says…

In my application i have a datagrid with itemrenderer as charts and I need have to perform two operations - one on single click and one on double click - on the chart. But most of the times double click event is not fired and if fired then single click is also fired. Can I stop single click event if double click event is fired ?

I investigated this and found this to be true. Once you enable doubleClick (by setting the doubleClickEnabled flag), whenever it occurs, a click event is also fired with it… I discussed this with Sreeni and he said that this is because the framework intends not to skip any event (because a double click is actually a click followed by a doubleClick event).

This may be useful in a lot of cases, but in Arpan’s case, this was causing havoc. The way to work around this is to write a Timer/Interval and use it to work around the problem. The following is the execution path…

  • On click, in the click handler, reset and initiate the timer which on complete, calls the deferredClickHandler (where the actual clickHandler code sits
  • If doubleClick does not occur, the timer completes and then executes the deferredClickHandler (I have kept my timer to be 300 mS)
  • If doubleClick occurs, it goes to the doubleClick handler, where you clear the timer (so that timer does not complete and execute the deferredClickHandler) and execute the doubleClickHandler code…

Caution: Do not forget to save the initial click Event if you need it later..

In Arpan’s case… he needs to use itemClick and itemDoubleClick events (of type ListEvent) instead of click & doubleClick (of type MouseEvent), as it is a DataGrid. The code below handles the case for both a DG & a Button… I have used the setInterval() method to implement the timer, you may as well use the Timer class…

### Kubernetes 中容器调度问题的解决方案 Kubernetes 作为一种高效的容器编排系统,能够自动处理容器的部署、扩展和管理。然而,在实际使用过程中,可能会遇到诸如资源不足、节点约束不匹配等导致容器调度失败的问题。 #### 1. **资源请求与限制配置不当** 如果 Pod 请求的 CPU 或内存资源超过集群中任何可用节点的容量,调度器将无法找到合适的节点来运行该 Pod。这种情况下,Pod 会保持在 `Pending` 状态,表示无法被调度 [^1]。 为避免此类问题,可以通过以下方式优化资源配置: - 合理设置容器的 `resources.requests` 和 `resources.limits`,确保其既不过高也不过低。 - 使用 Kubernetes 提供的资源管理功能,例如在 Pod 定义中指定 CPU 请求值: ```yaml spec: containers: - name: my-container image: nginx resources: requests: cpu: "100m" memory: "256Mi" limits: cpu: "500m" memory: "512Mi" ``` 通过这种方式,可以更有效地利用集群资源,并提高调度成功率 [^2]。 #### 2. **节点选择器与标签不匹配** Pod 可能因为指定了特定的节点选择器(Node Selector),而集群中没有具备相应标签的节点而导致调度失败。 解决方法包括: - 检查并更新节点上的标签,确保它们与 Pod 的 `nodeSelector` 匹配。 - 使用命令 `kubectl get nodes --show-labels` 查看所有节点及其标签信息。 - 在 Pod 定义中正确设置 `nodeSelector` 字段以指向目标节点组: ```yaml spec: nodeSelector: disktype: ssd ``` 这样可以确保 Pod 被调度到具有 SSD 存储类型的节点上 。 #### 3. **污点与容忍度不兼容** 当节点设置了污点(Taint)但 Pod 没有配置相应的容忍度(Toleration)时,Pod 将不会被调度到这些节点上。 为了克服这个问题,需要在 Pod 的定义中添加适当的容忍度条目。例如: ```yaml tolerations: - key: "key" operator: "Equal" value: "value" effect: "NoSchedule" ``` 此配置允许 Pod 被调度到带有指定键值对的节点上 [^1]。 #### 4. **持久化存储卷未就绪** 如果 Pod 使用了持久化存储卷(Persistent Volume, PV),但相关的 PVC(Persistent Volume Claim)尚未绑定到一个 PV,则 Pod 也无法启动。 要解决这个问题,应检查 PVC 的状态并通过以下步骤进行修复: - 使用 `kubectl get pvc` 命令查看 PVC 是否处于 `Bound` 状态。 - 如果 PVC 是 `Pending`,确认是否有足够的 PV 可用或者是否需要创建新的 PV 来满足 PVC 的需求 。 #### 5. **自定义调度器或插件问题** 对于采用自定义调度器的情况,某些非标准状态如 `PendingReds` 可能是由于调度逻辑中的特殊条件触发。这时应该审查调度器的日志文件来获取更多细节信息 [^1]。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值