I just installed Embarcadero C++Builder 10.4 Community Edition.
I created a new VCL-applcation and added some components TButton and TLabel to the form.
To the button I added an OnClick event:
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Button1->Caption = "Hej!";
}
//---------------------------------------------------------------------------
When I delete the button in the designer, the generated code is not deleted.
From Delphi 10.4 I know,that the generated code is removed.
Is this generally not working in C++Builder and do I need to remove the code manually?
I also tried a FMX application, it does not work either.
When I delete the button in the designer, the generated code is not deleted.
It is not supposed to. The IDE will remove an event handler only if the handler's body is completely empty. And even then, only when the unit is saved to disk, not when the component is removed from the Designer. If the handler has any code inside of it, even just comments, the IDE will leave it alone.
From Delphi 10.4 I know,that the generated code is removed.
I seriously doubt that. This behavior has been the same for many many years. There would be no reason for Embarcadero to change it now.
Related
I'm trying to develop my first Safari App Extension and I followed Apple's document on building a safari app extension and my Xcode version is 11.5. It appears that the extension worked, as I can see the extension button loaded on Safari navigation bar, and I can get the "Hello World!" from the injected script.js in SFSafariExtensionHandler subclass's messageReceived method when a page is loaded in Safari. So far so good with all with the code auto generated by Xcode when the Safari Extension was added. However, any modification of the script.js, like adding a new empty line, or just repeating the same dispatchMessage call, would render the extension unable to run , like the code below:
document.addEventListener("DOMContentLoaded", function(event) {
safari.extension.dispatchMessage("Hello World!");
safari.extension.dispatchMessage("Hello World!");
});
This is very frustrating, particularly considering the auto generated extension code already generates a ton of warning and error messages even when it appeared to be working. But I do see there are many Safari Extension products in App Store, so could anybody point me in the right direction?
Figured this out: we have to clean the build every time the script is modified. Then the extension debug run works again. Cleaning also works if we modified the info.plist and get code signing errors in debug runs.
I want to create a Xamarin Forms Editor Control that changes its height when it gets filled(Adds a new line when space in previous line finished). I'm only interested in WinPhone and Android Platfroms.
The Editor itself doesn't support such property.
I know that the Android native control (EditText) supports it (Not sure about the WinPhone variant, TextBox). But I'm not sure how to implement it.
It will be very helpful if someone can explain me how to create the renderers for these platforms.
Edit
I found this partial solution, it kind of works fine but it is not so natural(as for example EditText in Android).
class RoundedEditor : Editor
{
public RoundedEditor()
{
this.TextChanged += (sender, e) => { this.InvalidateMeasure(); };
}
}
I'll be glad if someone will provide a better solution.
Edit 2
Here are the results of how it works now:
UWP
Writing first line:
pressing enter:
The previous line is not showed completely as I would like.
Android
In android it actually works great:
You will have to implement a custom Android EditText, and then use it for your XamarinForms control (by implementing a custom renderer for it)
Take a look at this implementation of resizable EditText:
https://github.com/ViksaaSkool/AutoFitEditText
You'd have to translate it to C# obviously, but its a great start point.
Hi Xamarin/MvvmCross devs,
This is just a question out of curiosity. In one of the apps I'm developing some behaviour changed. Specifically on iOS when binding the UISwitch "On" value to a boolean in the ViewModel. The getter on the property fires when the binding is applied as well as the setter when the switch is flipped, but the UI does not reflect it. Forcing me to go from just
var set = this.CreateBindingSet<SettingsView, SettingsViewModel>();
set.Bind(PushNotificationSwitch).For(s => s.On)
.To(vm => vm.ReceivePushNotifications);
set.Apply();
To having to also add the following below that (to get the UI of the switch to reflect the value)
var settingsViewModel = ((SettingsViewModel)ViewModel);
PushNotificationSwitch.On = settingsViewModel.ReceivePushNotifications;
I left the binding, as well as the new code to reflect UI state, because in addition to the UI just reflecting the correct state, I also want it to change the state in my settingsService when the user changes it.
I recently upgraded through Xamarin Studio on Mac and my iOS Xam version is Version: 10.0.0.6. Unfortunately I didn't check what version I upgraded from, but I always upgrade as soon as I see there's one available, so it should be the previous stable version.
My questions are:
Has any of you experienced similar issues where bindings changed in this way?
Since the Android binding still works fine, do you think it's an issue in MvvmCross, or iOS Xamarin Changes
Any speculations as to what could be causing this? And other parts that you think this might affect, so I won't have to go scour for bugs if none exists. Commands, text and custom control bindings are working fine (as far as I've tested)
If this question would be better suited somewhere else please let me know, I'm just curious about this behaviour.
Thanks
As we worked out in the comments of the OP the event of the switch was linked out. Hence, the binding did nothing.
Easiest way to remedy this is to add the following code to your LinkerPleaseInclude.cs file, which MvvmCross provides in the Startup NuGet and through the templates available for Visual Studio and Xamarin Studio:
public void Include(UISwitch sw)
{
sw.On = !sw.On;
sw.ValueChanged += (sender, args) =>
{
sw.On = false;
};
}
This will tell the Linker that there is a direct usage of both the ValueChanged event and the On property, since the LinkerPleaseInclude class uses the Preserve attribute.
The title pretty much explains it. Here's the function to display the ColorDialog when a button is clicked:
void
CMyPP::OnBnClickedButtonCol()
{
CMFCColorDialog dlg(m_text_colour);
if (dlg.DoModal() == IDOK)
{
m_text_colour = dlg.GetColor();
}
}
In the release build nothing happens when the button is clicked. I can't see any difference in the VS 2008 options between debug and release to explain it. I think CMFCColorDialog is from the MFC feature pack but the rest of the program is basic MFC - could that explain it?
Thanks
Sorry, I missed out a crucial piece of information, in that the Debug version was using mfc in a shared dll while the release was static. Then I found this solution which has worked for me:
https://social.msdn.microsoft.com/Forums/en-US/7245ee72-ffd5-4167-b690-c2edc10fb88e/static-link-fails-with-vs2008-mfc-feature-pack .
Thanks for your help.
Good afternoon,
I am having an issue trying to conditionally comment out some code sections and objects inside code that is generated by Windows Forms Designer.
If I simply comment out these objects, the designer will show no issues with the code and will display what I am working on
If I comment out with #ifdef and #endif in the code, the designer gives me
"C++ CodeDOM parser error: Line: 358, Column: 1 --- Unexpected token for a 'term' "
and will not display the UI I am working on. However the code will compile just fine without errors.
Is there a way to conditionally comment out sections of the designer code in the Form.h file?
Thanks,
-D
Do not edit designer-generated code. If your change works then it is not going to live long, wiped out when the designer re-generates the code. And the real problem, the designer code parser can only understand the kind of code it generates itself. It is not a full-blown compiler, it doesn't know beans what #ifdef might mean. Which is what the error is trying to tell you.
If you need conditional changes then you need to make them in form's constructor, after the InitializeComponent() call. You can remove or add controls and change their properties as needed.