Press key & Commnd C + V and etc

void OnTextEntryCompletion(const char* str, int valIdx) override {
    SetStr(str[0] == '\0' ? "---- any info -----" : str);
    if (is_valid((char*)GetStr()))
    {
      OK->Hide(false);      
      // WIN press ENTER
      OK->Hide(false);
      if (GetKeyState(VK_RETURN) & 0x8000)
      {
        IMouseMod mod;
        OK->OnMouseDown(0,0, mod);
      }
      // WIN press ENTER
    }
    else {
      OK->Hide(true);
    }
  }

This code, implemented by pressing ENTER the appearance of the button in the version for WIN10

Are there any ideas on how to implement similar functionality for macOS in Iplug2?

Why shouldn’t this work for MacOS? Have you tried it?

XCode:

Use of undeclared identifier 'GetKeyState'

I know about the existence of kVK_RETURN but I don’t find any docs about use this on mac(. It may be necessary to connect some library, but I have no idea where to find its name…

Ah I see - you can possibly find it in SWELL (which is part of WDL which is an iplug2 dependency).

        OK->Hide(false);
        if (kVK_RETURN) // the same true but: ~GetKeyState(kVK_RETURN)
        {
          IMouseMod mod;
          OK->OnMouseDown(0,0, mod);
        }

kVK_RETURN is a constant, so that won’t do what you want. I meant that GetKeyState() might be found in SWELL.

/*
** GetAsyncKeyState()
** macOS: only supports VK_LBUTTON, VK_RBUTTON, VK_MBUTTON, VK_SHIFT, VK_MENU, VK_CONTROL (apple/command key), VK_LWIN (control key)
** GDK: only supports VK_LBUTTON, VK_RBUTTON, VK_MBUTTON, VK_SHIFT, VK_MENU, VK_CONTROL, VK_LWIN
*/
SWELL_API_DEFINE(WORD, GetAsyncKeyState,(int key))

Do you mean this code?

Ah - then it looks like that won’t work.

  Boolean isPressed(unsigned short inKeyCode)
  {
      unsigned char keyMap[16];
      GetKeys((BigEndianUInt32*) &keyMap);
      return (0 != ((keyMap[ inKeyCode >> 3] >> (inKeyCode & 7)) & 1));
  }
    
  void OnTextEntryCompletion(const char* str, int valIdx) override {
    SetStr(str[0] == '\0' ? "Enter..." : str);
    if (is_valid((char*)GetStr()))
    {
        OK->Hide(false);
        if(isPressed(kVK_Return))
        {
          IMouseMod mod;
          OK->OnMouseDown(0,0, mod);
        }
    }
    else {
      OK->Hide(true);
    }
  }
};

The fear is that this implementation is impossible to implement to copy/paste from the buffer. And other frameworks can do it, what am I wrong about I don’t understand.

@olilarkin
Please if you have something to add to this problem. I built IPlugControls and it doesn’t copy/paste on the mac either. I am aware that I deliberately ask the author of FRAMEWORK about what DOES NOT WORK.

Please don’t SHOUT or be rude. I don’t want to have to ban anyone else.

It is not clear to me what you are trying to do. It seems like you are trying to test keys in “OnTextEntryCompletion()” and then call another control’s OnMouseDown() method. This is weird and doesn’t make sense to me - it’s not a good way to do it. That is a call where you handle a string that has been typed into the text entry, after the text has been committed (return pressed)

If you can describe very clearly the exact thing you are trying to implement, then we might be able to suggest a better way to do it.

In IPlugControls I can can copy and paste values between text entries and e.g. into IEditableTextControl.

Can you explain what this is doing? Specifically, the return statement is somewhat interesting.

I wanted to say that I do not know what to do already in this situation. And I’m not asking you to write code for me or be rude or yell at someone. I want to figure out how to do the following without any problems (because there are no examples anywhere and I’m writing code that stinks):

There are two fields in the plugin for authorization, this is the login and password, we enter the login and password (or by copying) we do it. On both versions of operating systems.

What I want to implement:

I wrote a code in which I enter data and press enter. But the problem is this, there is no support for copying from the clipboard on Mac (More precisely, my code will not support it).

Understand you are asking for donations, I am ready to donate as much as I can. As long as you answer my stupid questions and make a list of them for future questioners.

And if you think that knowing some programming languages is so easy to write in C++ right away. Then I have bad news for you.

And if you think that I was rude to someone here and shouted at someone, then block me boldly right now.

Just run this code and you will see how it works. This is an implementation due to Carbon.h for registering keystrokes in C++

In fact, I rewrote C to C++ because I don’t have enough documents or examples…

Your attitude is bothering. Anyway…
The IEditableTextControl should do what you want. Even copying and pasting through keystrokes. Copy/Paste is additionally implemented by a right click menu.
OnTextEntryCompletion is called after pressing ‘Enter’. So this should do exactly what you want. At least it does here…

Did you check in different DAWs? E.g. Reaper may prevent to pass keystrokes to the plug if not explicitly allowed to.

@stw
Why am I going crazy. I’ll explain now. Without any additional code, it works great in any DAW on Windows and doesn’t work anywhere on Mac. (I meand → C+V).

For the purity of the experiment, you can build a regular [IPlugControls] and check CP in Logic Pro X for example… (https://github.com/iPlug2/iPlug2/tree/master/Examples/IPlugControls)

Logic is one of the DAWs which prevent copy/paste by key commands (at least AFAIK).
Since it’s mac only you won’t have any comparison to a windows machine. At least right click copy/paste is also available there.
Other DAWs (i checked Ableton, Reaper) are working fine and text or values can be copy/pasted in the plug.

@stw

Oh no…

https://streamable.com/t

Unfortunately, this is something you just have to work around since many DAWs steal keypresses.

Most plug-in devs put a button that pastes e.g. a serial number from the clipboard, since CMD-V is blocked. In iPlug you can get the contents of the clipboard with

IGraphics::GetTextFromClipboard(WDL_String &str)

2 Likes

BTW in Reaper… select “Send all keyboard input to plug-in” if you want the plug-in UI to receive CMD-V

1 Like