void CDiagramTextNode::onAddedToDiagram()
{
	m_p->clearSelection();
	m_brush = QBrush(Qt::NoBrush);
	m_pen.setColor( QColor(0, 0, 0, 0) );
	setEditing(true);
}
Exemple #2
0
void GuiSliderBase::keyboardEdit(int key)
{
    if (key==OF_KEY_RETURN)
    {
        if (editing)
        {
            setParameterValueFromString(editingString);
            setEditing(false);
        }
        else
        {
            setEditing(true);
            editingString = getParameterValueString();
        }
    }
    else if (key==OF_KEY_BACKSPACE)
    {
        if (!editing)
        {
            setEditing(true);
            editingString = getParameterValueString();
        }
        if (editingString.length() > 1)
        {
            editingString = editingString.substr(0, editingString.length()-1);
            valueStringNext = editingString;
            toUpdateValueString = true;
        }
    }
    else if (key == OF_KEY_LEFT)
    {
        decrement();
    }
    else if (key == OF_KEY_RIGHT)
    {
        increment();
    }
    else if ((key >= 48 && key <= 57) || key == 46)
    {
        if (!editing) {
            setEditing(true);
        }
        editingString += key;
        valueStringNext = editingString;
        toUpdateValueString = true;
    }
}
Exemple #3
0
bool GuiSliderBase::mouseMoved(int mouseX, int mouseY)
{
    GuiElement::mouseMoved(mouseX, mouseY);
    if (editing && !mouseOver) {
        setEditing(false);
    }
    return mouseOver;
}
Exemple #4
0
bool TextField::handleEventWithText(const char * eventText, bool indentation, bool forceCursorRightOfText) {
  size_t previousTextLength = strlen(text());

  size_t eventTextSize = strlen(eventText) + 1;
  char buffer[eventTextSize];
  size_t bufferIndex = 0;

  /* DIRTY
   * We use the notation "_{}" to indicate a subscript layout. In a text field,
   * such a subscript should be written using parentheses. For instance: "u_{n}"
   * should be inserted as "u(n)".
   * We thus remove underscores and changes brackets into parentheses. */
  bool specialUnderScore = false;
  for (size_t i = bufferIndex; i < eventTextSize; i++) {
    if (eventText[i] == '_') {
      specialUnderScore = ((i < eventTextSize - 1) && (eventText[i+1] == '{')) ? true : false;
      if (!specialUnderScore) {
         buffer[bufferIndex++] = '_';
      }
    } else if (eventText[i] == '{' && specialUnderScore) {
      buffer[bufferIndex++] = '(';
    } else if (eventText[i] == '}' && specialUnderScore) {
      buffer[bufferIndex++] = ')';
      specialUnderScore = false;
    } else {
      buffer[bufferIndex++] = eventText[i];
    }
  }

  int cursorIndexInCommand = TextInputHelpers::CursorIndexInCommand(buffer);

  int newBufferIndex = 0;
  // Remove EmptyChars
  for (size_t i = newBufferIndex; i < bufferIndex; i++) {
    if (buffer[i] != Ion::Charset::Empty) {
      buffer[newBufferIndex++] = buffer[i];
    }
  }

  if (!isEditing()) {
    setEditing(true);
  }
  int nextCursorLocation = draftTextLength();
  if (insertTextAtLocation(buffer, cursorLocation())) {
    /* The cursor position depends on the text as we sometimes want to position
     * the cursor at the end of the text and sometimes after the first
     * parenthesis. */
    nextCursorLocation = cursorLocation() + (forceCursorRightOfText? strlen(buffer) : cursorIndexInCommand);
  }
  setCursorLocation(nextCursorLocation);
  return m_delegate->textFieldDidHandleEvent(this, true, strlen(text()) != previousTextLength);
}
Exemple #5
0
  kGame()
  {
    gui = new kGui(this);
    m_gamemode = true;

    setMsAbsolute(true);

    if(m_physics)
      m_physics->m_gravity = 1.0f;

    if(m_logic)
      m_logic->release();

    m_logic = new kLogic(this);

    data.sig  = 0xffff;
    data.cmap = 1;
    data.umaps = 1;

    readData();
    saveData();

    g_maps_unlock = data.umaps;
    gui->updateMaps((char**)g_maps, (u32)data.umaps);

    kgmGameObject::goRegister("aKomble",    kgmGameObject::GoActor, (kgmGameObject::GenGo)&aKomble::New);
    kgmGameObject::goRegister("aBear",      kgmGameObject::GoActor, (kgmGameObject::GenGo)&aBear::New);
    kgmGameObject::goRegister("aBearBoss",  kgmGameObject::GoActor, (kgmGameObject::GenGo)&aBearBoss::New);
    kgmGameObject::goRegister("aWolf",      kgmGameObject::GoActor, (kgmGameObject::GenGo)&aWolf::New);
    kgmGameObject::goRegister("aWolfBoss",  kgmGameObject::GoActor, (kgmGameObject::GenGo)&aWolfBoss::New);
    kgmGameObject::goRegister("aFox",       kgmGameObject::GoActor, (kgmGameObject::GenGo)&aFox::New);
    kgmGameObject::goRegister("aFoxBoss",   kgmGameObject::GoActor, (kgmGameObject::GenGo)&aFoxBoss::New);

#ifdef EDITOR
    setEditing(true);

    if(editing)
      gui->m_guiMain->hide();
#endif
  }
Exemple #6
0
bool TextField::privateHandleEvent(Ion::Events::Event event) {
  if (Responder::handleEvent(event)) {
    /* The only event Responder handles is 'Toolbox' displaying. In that case,
     * the text field is forced into editing mode. */
    if (!isEditing()) {
      setEditing(true);
    }
    return true;
  }
  if (event == Ion::Events::Left && isEditing() && cursorLocation() > 0) {
    return setCursorLocation(cursorLocation()-1);
  }
  if (event == Ion::Events::ShiftLeft && isEditing()) {
    return setCursorLocation(0);
  }
  if (event == Ion::Events::Right && isEditing() && cursorLocation() < draftTextLength()) {
    return setCursorLocation(cursorLocation()+1);
  }
  if (event == Ion::Events::ShiftRight && isEditing()) {
    return setCursorLocation(draftTextLength());
  }
  if (isEditing() && textFieldShouldFinishEditing(event)) {
    char bufferText[ContentView::k_maxBufferSize];
    strlcpy(bufferText, m_contentView.textBuffer(), ContentView::k_maxBufferSize);
    strlcpy(m_contentView.textBuffer(), m_contentView.draftTextBuffer(), m_contentView.bufferSize());
    int cursorLoc = cursorLocation();
    setEditing(false, m_hasTwoBuffers);
    if (m_delegate->textFieldDidFinishEditing(this, text(), event)) {
      /* We allow overscroll to avoid calling layoutSubviews twice because the
       * content might have changed. */
      reloadScroll(true);
      return true;
    }
    /* if the text was refused (textInputDidFinishEditing returned false, we
     * reset the textfield in the same state as before */
    char bufferDraft[ContentView::k_maxBufferSize];
    strlcpy(bufferDraft, m_contentView.textBuffer(), ContentView::k_maxBufferSize);
    setText(bufferText);
    setEditing(true);
    setText(bufferDraft);
    setCursorLocation(cursorLoc);
    return true;
  }
  if (event == Ion::Events::Backspace && isEditing()) {
    return removeChar();
  }
  if (event == Ion::Events::Back && isEditing()) {
    setEditing(false);
    reloadScroll();
    m_delegate->textFieldDidAbortEditing(this);
    return true;
  }
  if (event == Ion::Events::Clear && isEditing()) {
    if (!removeEndOfLine()) {
      setEditing(true, true);
    }
    return true;
  }
  if (event == Ion::Events::Copy && !isEditing()) {
    Clipboard::sharedClipboard()->store(text());
    return true;
  }
  if (event == Ion::Events::Cut && !isEditing()) {
    Clipboard::sharedClipboard()->store(text());
    setEditing(true, true);
    return true;
  }
  return false;
}