标签: handler

CefSharp 浏览器不会在 C# WinForms 应用程序中触发任何鼠标事件

所以我的最终目标是检测用户何时在网页上按下鼠标左键(任何元素,如按钮、图像等)。有了这个,我将运行一些 javascript 来根据用户点击的位置获取我需要的正确的 html 数据。

不用再进一步,我已经陷入了第一部分,我的浏览器控件似乎没有触发任何与鼠标相关的事件。然而,它似乎确实提供了像 MouseDown、MouseEnter、MouseClick 等处理程序,但似乎没有触发它们中的任何一个。

我尝试使用文本框控件和按钮设置一个简单的 WinForms 测试项目。浏览器是手动添加的,如下所示:

using CefSharp;
using CefSharp.WinForms;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace myProject
{
    public partial class Form1 : Form
    {
        public ChromiumWebBrowser browser;
        private string myUrl = "https://www.google.com/";
        
        public Form1()
        {
            InitializeComponent();
            InitializeChromium();

            browser.MouseDown += ChromeBrowser_MouseDown;
        }

        public void InitializeChromium()
        {
            browser = new ChromiumWebBrowser(myUrl);

            browser.Location = new Point(26, 59);
            browser.Size = new Size(988,566);
            browser.Dock = DockStyle.None;
            this.Controls.Add(browser);

        }

        private void ChromeBrowser_MouseDown(object sender, MouseEventArgs e)
        {
            //This handler never …
Run Code Online (Sandbox Code Playgroud)

c# handler winforms mousedown cefsharp

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

如何使用 typescript 在本地测试 AWS Lambda 处理程序

我已按照typescriptLambda说明创建基本的 typescript lambda。现在,我想像testNodeJsLambda一样在本地执行代码,但我在定义事件和上下文时遇到了困难。

import {APIGatewayProxyCallback, Context} from 'aws-lambda';
import {APIGatewayEvent} from "aws-lambda";

     export const handler = async (
         event: APIGatewayEvent, context: Context, callback: APIGatewayProxyCallback ) => {
         console.log (`Test`)
         callback(null, {
             statusCode: 200,
          body: JSON.stringify(recordingStatus)});   
    }
Run Code Online (Sandbox Code Playgroud)

如何定义事件和上下文?空物体{}是不可接受的。

事件的代码是:

import {APIGatewayEvent, Context} from 'aws-lambda';
const event : APIGatewayEvent = {
        body: null,
        headers: {},
        multiValueHeaders: {},
        httpMethod: "POST",
        isBase64Encoded: false,
        path: "/path/to/resource",
        pathParameters : null,
        queryStringParameters : null,
        multiValueQueryStringParameters : null,
        stageVariables : null,
        requestContext: …
Run Code Online (Sandbox Code Playgroud)

unit-testing handler amazon-web-services typescript aws-lambda

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

如何在Android中停止线程和处理程序

老实说,我无法弄明白 - 我听说这thread.stop()不是一件好事.它也不适合我.如何让线程/处理程序停止运行?

android handler

0
推荐指数
1
解决办法
5895
查看次数

信号处理程序内部的变量更新永远不会更新

在信号处理程序中,我正在改变变量的值.但是,程序从未注意到更新,即使我已将变量leader_barrier声明为sig_atomic_t.

void timer_action(int signum)
{   
static int count = 0;

 if ( !(*pbarrier_in_proc) && !(leader_barrier) && !(*pno_more) )
  leader_barrier = 1;
}
Run Code Online (Sandbox Code Playgroud)

并且它确认了timer_action确实执行并且leader_barrier确实在其中变为1,正如我通过在信号处理程序中打印其值所看到的那样.

c linux signals handler

0
推荐指数
1
解决办法
357
查看次数

java.lang.RuntimeException:无法在未调用Looper.prepare()的线程内创建处理程序

当单击一个按钮时,我使用简单的线程来执行httpGet到服务器,但是我在执行后得到了这个.

Button b_back = (Button) findViewById(R.id.bback);
b_back.setOnClickListener(this);
Button b_sign_up = (Button) findViewById(R.id.signup_button);
b_sign_up.setOnClickListener(this);

@Override
public void onClick(View arg0) 
{
    // TODO Auto-generated method stub
    switch (arg0.getId()) 
    {
        case R.id.bback:
            Intent i = new Intent(this, MainSwitch.class);
            finish();
            startActivity(i);
            break;

            // More buttons go here (if any) ...

        case R.id.signup_button:
            if(username.getText().toString().equalsIgnoreCase("") ||
               password.getText().toString().equalsIgnoreCase("") ||
               email.getText().toString().equalsIgnoreCase(""))
            {
                AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                dialog.setMessage("Please fill in all the gaps!");
                dialog.show();
            }
            else
            {
                //****** Call method that sends the information to server.
                Thread background …
Run Code Online (Sandbox Code Playgroud)

java multithreading android handler looper

0
推荐指数
1
解决办法
9759
查看次数

在android中添加视图时添加延迟

我有一个简单的动画附加到我正在创建的动态textview但我想要的是添加它们时添加延迟.请指导我如何做到这一点.

    LinearLayout ll = (LinearLayout)findViewById(R.id.ll);
    final HorizontalScrollView hsv = new HorizontalScrollView(TestViewActivity.this);
    LinearLayout lhsv = new LinearLayout(TestViewActivity.this);

    Animation a1 = new AlphaAnimation(0.00f, 1.00f);
    a1.setDuration(350);
    a1.setFillAfter(true);  

    for(int k =0; k < 5; k++){
        // may be some handler here but how ?
        TextView tv = new TextView(TestViewActivity.this);
        tv.setText("Text");
        tv.setTextSize(42);
        tv.setPadding(10, 0, 10, 0);
        tv.setVisibility(View.INVISIBLE);
        tv.clearAnimation();
        tv.startAnimation(a1);

        lhsv.addView(tv, k);
    }

    hsv.addView(lhsv);

    ll.addView(hsv);
Run Code Online (Sandbox Code Playgroud)

谢谢

基于建议我已经尝试过它可行,但是所有视图都在一起,我想要的是一个视图输入然后一点延迟然后另一个视图输入等等...这是代码.

   final Handler handler = new Handler();
    LinearLayout ll = (LinearLayout)findViewById(R.id.ll);
    final HorizontalScrollView hsv = new HorizontalScrollView(TestViewActivity.this);
    final LinearLayout lhsv …
Run Code Online (Sandbox Code Playgroud)

android handler postdelayed

0
推荐指数
1
解决办法
3460
查看次数

使用多个表加载DataTable选择查询

我以前从未使用过涉及多个表的选择查询,现在当我这样做时,我遇到了从中获取信息的麻烦DataTable.

我有这个问题:

SELECT * 
FROM [Usergroups], [Groups] 
WHERE [Usergroups.UserID] = @name 
  AND [Groups.GroupID] = [Usergroups.GroupID]
Run Code Online (Sandbox Code Playgroud)

这就是我将返回值放入DataTable的方法:

DataTable groupsTable = new DataTable();
groupsTable.Load(sqlCmd.ExecuteReader());
Run Code Online (Sandbox Code Playgroud)

现在,我如何指定我DataTable想从哪个表中获取行?例如,这是我在涉及的多个表之前所做的事情:

string groupName = groupsTable.Rows[0]["Name"];
Run Code Online (Sandbox Code Playgroud)

我找不到任何有此类信息的资源,但我知道这是一个基本问题.提前致谢.

.net c# sql datatable handler

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

信号系统调用

我有这个代码片段,我甚至读了几次信号系统调用,我仍然不明白为什么程序停止第四次我按CTRL-C,而不是第三次.提前致谢!

#include <stdio.h>
#include <signal.h>
#include <unistd.h>

int i=0;

void handler(int sig)
{
    i++;
    printf("CTRL-C\n");
    if (i==3)
        signal(SIGINT, SIG_DFL);
}

int main()
{
    signal(SIGINT,handler);
    while (1)
    {
        printf("Hello world!\n");
        sleep(1);
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我读到信号系统调用不可移植,所以如果我提到我使用的是最新版本的Ubuntu(14.04),它可能会有所帮助.

c linux signals system-calls handler

0
推荐指数
1
解决办法
133
查看次数

Swift 2到Swift 3:无法将类型'(Data?,NSError?) - > Void'的值转换为预期的参数类型'GTMSessionFetcherCompletionHandler?'

我刚刚更新了一个正在运行的Swift 2到Swift 3程序,我收到了错误,

无法将'(Data?,NSError?) - > Void'类型的值转换为预期的参数类型'GTMSessionFetcherCompletionHandler?'

以下是相关细节(我希望):

let fetcher = GTMSessionFetcher(urlString:url)
fetcher.authorizer = parentController.service.authorizer
fetcher.beginFetch(completionHandler: handleDownload(studentNum))
                                      ^^^^ causing the error
Run Code Online (Sandbox Code Playgroud)

completionHandler的函数:

func handleDownload(_ studentNum:Int) -> (Data?, NSError?) -> Void {
    return { (data: Data?, error: NSError?) -> Void in
        // code for function
    }
}
Run Code Online (Sandbox Code Playgroud)

GTMSessionFetcherCompletionHandler 在Objective-C头文件中定义,如下所示:

#define GTM_NULLABLE_TYPE __nullable
typedef void (^GTMSessionFetcherCompletionHandler)(NSData * GTM_NULLABLE_TYPE data,
                                               NSError * GTM_NULLABLE_TYPE error);
Run Code Online (Sandbox Code Playgroud)

我尝试将handleDownload()更改为以下内容:

func handleDownload(_ studentNum:Int) -> (GTMSessionFetcherCompletionHandler?) {
    return { (data: Data?, error: NSError?) -> Void in
       // code for …
Run Code Online (Sandbox Code Playgroud)

handler swift swift3

0
推荐指数
1
解决办法
6243
查看次数

HTML属性中事件处理程序中的“ this”

我以为我会理解“ this”关键字,直到看到以下代码:

<body>
    <button onclick="go()">clic1</button>

    <button id="btn">clic2</button>

    <script>

        function go() {
            console.log(this);
        }

        var btn = document.getElementById("btn");
        btn.onclick = function() {
            console.log(this)
        }

    </script>
</body>
Run Code Online (Sandbox Code Playgroud)

我有一个HTML文档,其中包含两个按钮,它们在单击时会执行相同的操作:它们记录了“ this”关键字。

我很惊讶他们没有显示出相同的结果:

对于按钮“ clic1”:this = Window

对于按钮“ clic2”:这= ID为“ btn”的按钮对象

有什么解释吗?

谢谢

javascript this handler

0
推荐指数
1
解决办法
78
查看次数