Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IWButtons Hotkey property and the &-sign in Captions
#11
(09-21-2019, 01:36 PM)JuergenS Wrote: Hi Soren,

this is an C++ example of handling a button event from an edit control
which also requires little effort and of course can be implemented in Delphi:

void __fastcall TIWFormEdit::IWEditAsyncKeyDown(TObject *Sender, TStringList *EventParams)
{
    if(vkF10 == EventParams->ValueFromIndex[EventParams->IndexOfName(L"which")].ToInt())
    {
        // Call your corresponding button event handler
        IWButtonClick(Sender);
    }
}

Regards
Juergen

Hi JuergenS,

thanks. I'll check it out. It look like I would normally do it in Delphi, though it is on the form I need it. Not a particular edit control.

Regards
Soren
Reply
#12
Re JS...

https://hackernoon.com/how-it-feels-to-l...a717dd577f

This is why IW17 will rule Smile
Reply
#13
(09-20-2019, 09:02 PM)SorenJensen Wrote: Hi Kudzu,

Or do you prefer I say Hi Chad (or chad) after reading your article.

The coding was wrong and as soon as I changed the c to a C in keyCode, the script worked as expected. I can see what camelCasing is, but fail to see the benefit of it. However, being use to a case insensitive programming language, I learned to use something similar from start. Using capital letter for every part of a word with different meaning. Like KeyCode, GetCustomer, PostItem, SaveItemsToFile and so on. I do also distinguish spelling between vars, types and procedure/function names, but mostly in the words I use. Using saying names, even though they do become a bit longer than necessary. All in the interest of understanding when reading the code 3-4-5 year later...

Thanks for the simple, yet completely unnoticed difference in the script. I'm sure it would have taken me a long time to find it.

And thanks for the link to the interesting article, to which I fully agree. A lot of time have been, and will continue to be wasted in development.

Regards
Soren

Camel case is a convention. Like any other convention related to source code it makes it easier to identify things based on how it looks. Functions in JavaScript use camelCase convention. I tend to agree with it and I use it whenever I'm writing code in languages that use it (like JavaScript and C#). I don't use camelCase in Pascal on the other hand. The convention for Pascal is that it should use (surprise!) PascalCase everywhere.
It is much better to write code that looks familiar to any developer than to develop a complete new formatting and style which will look like alien writing to other devs and vice-versa.

In IW not all JS code uses that convention for various reasons but all newer code does use it.
Reply
#14
(09-21-2019, 01:36 PM)JuergenS Wrote: Hi Soren,

this is an C++ example of handling a button event from an edit control
which also requires little effort and of course can be implemented in Delphi:

void __fastcall TIWFormEdit::IWEditAsyncKeyDown(TObject *Sender, TStringList *EventParams)
{
    if(vkF10 == EventParams->ValueFromIndex[EventParams->IndexOfName(L"which")].ToInt())
    {
        // Call your corresponding button event handler
        IWButtonClick(Sender);
    }
}

Regards
Juergen

You don't need all this to retrieve the parameter value. You can use property Values of TStringList type to get exactly what you want:

Code:
void __fastcall TIWForm1::IWButton1AsyncClick(TObject *Sender, TStringList *EventParams)

{
  UnicodeString key = EventParams->Values["which"];
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)