android.view.KeyEvent.dispatch()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中android.view.KeyEvent.dispatch()方法的一些代码示例,展示了KeyEvent.dispatch()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.dispatch()方法的具体详情如下:
包路径:android.view.KeyEvent
类名称:KeyEvent
方法名:dispatch

KeyEvent.dispatch介绍

暂无

代码示例

代码示例来源:origin: k9mail/k-9

public void emulateShiftHeld() {
  try {
    KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
                        KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
    shiftPressEvent.dispatch(this, null, null);
    Toast.makeText(getContext() , R.string.select_text_now, Toast.LENGTH_SHORT).show();
  } catch (Exception e) {
    Timber.e(e, "Exception in emulateShiftHeld()");
  }
}

代码示例来源:origin: ankidroid/Anki-Android

/**
 * Select Text in the webview and automatically sends the selected text to the clipboard. From
 * http://cosmez.blogspot.com/2010/04/webview-emulateshiftheld-on-android.html
 */
@SuppressWarnings("deprecation") // Tracked separately in Github as #5024
private void selectAndCopyText() {
  try {
    KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
    shiftPressEvent.dispatch(mCard);
    shiftPressEvent.isShiftPressed();
    mIsSelecting = true;
  } catch (Exception e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: stackoverflow.com

private void emulateShiftHeld(WebView view)
 {
   try
   {
     KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
                         KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
     shiftPressEvent.dispatch(view);
     Toast.makeText(this, "select_text_now", Toast.LENGTH_SHORT).show();
   }
   catch (Exception e)
   {
     Log.e("dd", "Exception in emulateShiftHeld()", e);
   }
 }

代码示例来源:origin: BCsl/TwoWayGallery

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  // Gallery steals all key events
  return event.dispatch(this, null, null);
}

代码示例来源:origin: binaryroot/CarouselView

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  // Carousel view steals all key events
  return event.dispatch(this, null, null);
}

代码示例来源:origin: kingargyle/adt-leanback-support

@Override
public void handleKey(KeyEvent key) {
  key.dispatch(mKeyEventCallback);
}
@Override

代码示例来源:origin: souliss/soulissapp

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  // Gallery steals all key events
  return event.dispatch(this, null, null);
}

代码示例来源:origin: dalong982242260/CarrouselView

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  // Gallery steals all key events
  return event.dispatch(this, null, null);
}

代码示例来源:origin: wuzhendev/android-wgallery

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  // Gallery steals all key events
  return event.dispatch(this, null, null);
}

代码示例来源:origin: stackoverflow.com

public void SelectText(View v) {
   try {
     KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
         KeyEvent.KEYCODE_ESCAPE, 0, 0);
     shiftPressEvent.dispatch(v);
   } catch (Exception e) {
     throw new AssertionError(e);
   }
 }

代码示例来源:origin: stackoverflow.com

public void SelectText(){  
 try{  
  KeyEvent shiftPressEvent =   
       new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,       
       KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);  
  shiftPressEvent.dispatch(myWebView);  
}catch(Exception e){  
  throw new AssertionError(e);  
}

代码示例来源:origin: stackoverflow.com

public void SelectText(View v) {
  try {
    KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
        KeyEvent.KEYCODE_ESCAPE, 0, 0);
    shiftPressEvent.dispatch(v);
  } catch (Exception e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: stackoverflow.com

/**
 * Select Text in the webview and automatically sends the selected text to the clipboard
 */
public void selectAndCopyText() {
  try {
   KeyEvent shiftPressEvent = new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
   shiftPressEvent.dispatch(mWebView);
  } catch (Exception e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: stackoverflow.com

public void selectnCopy() {
  Toast.makeText(WebClass.this,getString(R.string.select_help),Toast.LENGTH_SHORT).show();
  try {
    KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
        KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
    shiftPressEvent.dispatch(wv);
  } catch (Exception e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: stackoverflow.com

public void selectAndCopyText() {
try {
  Method m = WebView.class.getMethod("emulateShiftHeld", null);
  m.invoke(this, null);
} catch (Exception e) {
  e.printStackTrace();
  // fallback
  KeyEvent shiftPressEvent = new KeyEvent(0,0,
     KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
  shiftPressEvent.dispatch(this);
}

代码示例来源:origin: stackoverflow.com

public void selectAndCopyText() {
try {
  Method m = WebView.class.getMethod("emulateShiftHeld", null);
  m.invoke(this, null);
} catch (Exception e) {
  e.printStackTrace();
  // fallback
  KeyEvent shiftPressEvent = new KeyEvent(0,0,
     KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
  shiftPressEvent.dispatch(this);
}

代码示例来源:origin: stackoverflow.com

public void selectAndCopyText() {
  try {
    Method m = WebView.class.getMethod("emulateShiftHeld", null);
    m.invoke(this, null);
  } catch (Exception e) {
    e.printStackTrace();
    // fallback
    KeyEvent shiftPressEvent = new KeyEvent(0,0,
       KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
    shiftPressEvent.dispatch(this);
  }
}

代码示例来源:origin: stackoverflow.com

public void selectAndCopyText() {
   try {
     Method m = WebView.class.getMethod("emulateShiftHeld", Boolean.TYPE); 
      m.invoke(BookView.mWebView, false); 
    } catch (Exception e) {
      e.printStackTrace();
      // fallback
      KeyEvent shiftPressEvent = new KeyEvent(0,0,
         KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
      shiftPressEvent.dispatch(this);
    }

}

代码示例来源:origin: fengdai/FragmentMaster

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  final View decor = mActivity.getWindow().getDecorView();
  return event.dispatch(mActivity, decor != null ? decor.getKeyDispatcherState() : null, mActivity);
}

代码示例来源:origin: fengdai/FragmentMaster

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  View view = mMasterFragment.getView();
  return event.dispatch(mMasterFragment, view != null ? view.getKeyDispatcherState() : null, this);
}

相关文章