WideStudio Logo
WideStudio
Programming Guide
WideStudio Index
Table of contents


编辑范例事项过程的输入区域



使用回车键实行特定的事项过程

在事项过程中,试着启动特定的事项过程。这里,我们将启动名为”输入确定”的事项过程。

use mpfc;
# A sample of WSEV_KEY_HOOK trigger.
sub cbop {
  my ($object) = @_;
  # (A)Get the pressed key.
  $key = mpfc::WSDkeyboard_getKey(mpfc::WSGIappKeyboard());

  # (B)f the key is return..
  if ($key == $mpfc::WSK_Return){
    # Execute the procedure which name is "InputFixed".
    mpfc::WSCbase_execProcedure($object,"InputFixed");
  }
  return;
}
1;

(A)通过键盘取得正在输入的文字。

(B)判断输入值是否为回车键,如果是,在(C)启动名为”输入确定”的EP。 这种通过输入确认是否实行事项过程的方法,常常被使用于通过输入回车键确定动作的情况。

输入文字时自动删除既有字符

接着制作当光标处开始输入新的文字时,该区域中既有字符自动删除的事项过程。大概的流程。如下。

use mpfc;
#To contain the last focused input field.
$focus_if = 0;

# A sub-procedure with WSEV_FOCUS_CH
sub _focus_ch_ {
  my ($object) = @_;
  # (A) Examine whether the Instance is focused.
  if ($focus_if != 0 &&
      mpfc::WSCbase_getInstanceName($focus_if) != mpfc::WSCbase_getInstanceName($object) &&
      mpfc::WSCbase_getFocus($object) != &mpfc::False ){

    # (B)It need to clear the string!
    # Set the clear flag True.
    mpfc::WSCbase_setVariantData($object,"CLEAR TIMING",1);
    # (C)store that the last focused one is.
    $focus_if = $object;
  }
  return;
}
#A sub-procedure with WSEV_MOUSE_PRESS
sub _btn_press_ {
  my ($object) = @_;
  # (D) if clicked by the mouse pointer,
  # it needs to clear the string!Set the clear flag True.
  mpfc::WSCbase_setVariantData($object,"CLEAR TIMING",1);
  mpfc::WSCbase_setProperty($object,"cursorPos",0);
  # (E)store that the last focused one is.
  $focus_if = $object;
  return;
}
# A sub-procedure with WSEV_KEY_PRESS
sub _key_hook_ {
  my ($object) = @_;
  # (F)See the clear flag to clear the last input string.
  $fl = mpfc::WSCbase_getVariantData($object,"CLEAR TIMING");
  if (mpfc::WSCvariant_getLong($fl) == 1){
    $key = mpfc::WSDkeyboard_getKey(mpfc::WSGIappKeyboard());
    # (G)Clear the string,if the key is not cursor key.
    if ($key != $mpfc::WSK_Tab &&
        $key != $mpfc::WSK_Up &&
        $key != $mpfc::WSK_Down &&
        $key != $mpfc::WSK_Left &&
        $key != $mpfc::WSK_Right ){
      # (H)Clear...
      mpfc::WSCbase_setProperty($object,"labelString","");
    }else{
      return;
    }
  }
  # (I)Set the clear flag False.
  mpfc::WSCbase_setVariantData($object,"CLEAR TIMING",0);
  return;
}

# Set the clear flag False.
# Set the input field Instance with WSEV_INITIALIZE trigger.
sub ifdclr {
  my ($object) = @_;
  # Setup the sub-procedure(1) with WSEV_FOCUS_CH
  mpfc::WSCbase_addProcedure($object,"ac1","_focus_ch_",$mpfc::WSEV_FOCUS_CH);

  # Setup the sub-procedure(2) with WSEV_MOUSE_PRESS
  mpfc::WSCbase_addProcedure($object,"ac2","_btn_press_",$mpfc::WSEV_MOUSE_PRESS);

  #Setup the sub-procedure(3) with WSEV_KEY_PRESS
  mpfc::WSCbase_addProcedure($object,"ac3","_key_hook_",$mpfc::WSEV_KEY_HOOK);
}
1;

首先对光标关联的子项目EP进行说明。为了知道光标是否改变了位置,以静态变量预先保持上次光标位置。

(A),判断现位置与预先保持的位置是否不同。如果不同,即可知道光标被改变,在(B)处启动删除处理。然后在(C)处将该静态变量赋予自身。

然后对鼠标点击相关的子项目EP进行说明。在(D)处启动删除处理,并设定输入光标于前头。然后在(E)处将新的值赋予光标保持的静态变量中。

然后对键入关联的子项目EP进行说明。该子项目EP中,如果删除处理已被启动,将删除字符串,并结束删除处理。首先,在(F)处判断删除处理是否启动中。在(G)处辨别新输入文字,在(H)删除既有文字,在(I)处结束删除处理。

Document Release 3.70 for WideStudio ver 3.70, Feb 2004


WideStudio documents index | Table of contents

Copyright(C) T. Hirabayashi, 2000-2004 Last modified: Feb 25, 2004