Can you use AddEventListener with CEF4Delphi? - delphi

I am using Delphi XE2 and Chromium CEF4Delphi. I am trying to use a web page via the TChromiumWindow component and would like to detect when an element is selected / clicked.
I saw this post..
Delphi Chromium - launch a command in Delphi application when button in web page is clicked by user
Unfortunately, I cant find the function AddEventListenerProc in the CEF4Delphi library. Neither can I find an alternative way to monitor a button / element click.
I would like to use the TChromiumWindow component to act as a "fron-end" to my app and would like to monitor user button clicks etc.
Can anyone help please ? I did try the developer forum but I dont see much activity there and was unable to register.
Many thanks..

The DCEF3 project has a group here : https://groups.google.com/forum/#!forum/delphichromiumembedded
But the CEF4Delphi and OldCEF4Delphi projects have a developers forum here :
https://www.briskbard.com/forum/
That forum has new posts almost every day and I try to answer them as soon as I can, usually in less than 24 hours.
If you have problems creating an account just send me a message and I'll activate your account manually.
The link you posted is very old and many things have changed in CEF since 2012.
There are several ways to detect when a HTML element has been selected, clicked, etc.
You can use a JavaScript event like "onclick" that calls a custom JavaScript extension. That extension would send a process message to the browser process to notify that the user clicked that element.
You can also use the GlobalCEFApp.OnFocusedNodeChanged that is triggered when an HTML element has been focused. This event is executed in the "render" process so you will also need to send a process message to the main browser process that the focused element has changed.
Use the JSRTTIExtension or the JSExtension demos as a template for your app.
They show you how to set a "mouseover" event that calls the "myextension.mouseover" function defined in a custom JS extension. The myextension.mouseover function executes Delphi code and sends a process message to the main browser process with some HTML information that is shown in the status bar.
They also have an example for a "MutationObserver" that calls a generic "myextension.sendresulttobrowser" function in the JS extension that sends the "value" attribute to the browser process.
Build the demo and right-click on the web page when it's fully loaded. Then select the "Set mouseover event" or "Add mutation observer" options to test what I described.

Related

Umbraco - editing preview window sidebar options

I have a project which is using Umbraco v7.7.9 installed with nuget.
I was wondering if it is possible to change the buttons displayed in the sidebar section when a user selects to preview a content node. Particularly I want to remove the option that allows the user to close the preview.
The reason I want to hide this option is because some of the content the backoffice users will be previewing will not actually be published yet so clicking the close preview button causes an error.
I first asked this question on the Umbraco forums but haven't received a response yet, here is the link to the question: https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/90878-editing-preview-window-sidebar-options
Thank you in advance.
Currently no - it would not be possible without doing hacks in the Core that would be overwritten when you upgrade your site (unless you manually merge your changes in when updating).
If you however don't mind doing that - the file used for the preview function is /umbraco/preview/index.html. You should look for the element with an exitPreview() click handler attached to it.
In later versions (7.10+) this modification will have to be done in /umbraco/Views/Preview/Index.cshtml instead, as these static files will be changed to MVC actions.

Detecting Quick Access command state

We have an application that is using Windows Ribbon Framework for an UI. The app itself is written in Delphi and uses Windows Ribbon Framework for Delphi to interface with the ribbon API.
Our ribbon XML places few commands into the Quick Access toolbar. Use can then remove/add commands either by using the built-in ribbon mechanism (selecting the drop/down button and clicking on a command name) or by selecting More commands command which opens the configuration dialog.
The problem I've encountered is that I cannot find a way to get the current state of commands in the QA collection (whether they are visible or not).
In the example above (picture) I would like to detect that first five commands are checked and that the last is not so I can prepare the configuration dialog accordingly.
I have no problems enumerating the IUICollection and accessing the items stored inside. I can also get the UI_PKEY_CommandId for each item. I cannot, however, find a way to read the checked/unchecked state. I tried reading UI_PKEY_BooleanValue and UI_PKEY_Enabled for all items in the collection, but they do not return that state.
I have also tried to monitor IUICommandHandler.UpdateProperty but it doesn't get called when such item is checked/unchecked (except that it is called with the UI_PKEY_Label key).
Does ribbon API even support this functionality?

Adobe Analytics event firing on every page

I'm using DTM to implement Adobe Analytics code on a single page app.
I have a link that we've set up successfully as an exit link and it fires as it should. If this matters, it opens in a new tab and we don't actually exit the website. However, any time we fire off any subsequent page views, we see the same event fired. Is there any way to fire off this event only when the link actually is clicked? I assume that because it's a one page app and the code isn't getting refreshed that is the reason it's on every subsequent page.
Using Adobe Analytics and DTM is frustrating with single page apps. What we do is clear all the variables that are set before each page view. We have a function that clears, props, evars, events, listVars, heir, pageName etc.
Please check witch version of s_code you are using, if you are using Appmeasurement or one of the last s_code versions please use clearkVars() function.
following code is a log from browser console with console responses:
s.events ="event1"
"event1"
s.linkTrackVars='events';
"events"
s.eVar1="value"
"value"
s.clearVars();
undefined
s.events
undefined
s.eVar1
undefined
you can fire this in custom code section (if your custom code section is set to fire after gui settings, or you can fire it as JavaScript 3rd party tag.

Tab order in a console app with a single VCL form

I have a Windows console app created with Embarcadero XE 6 (in fact converted from a Borland C++Builder5 project). It has a single form with a few buttons and edit controls. All these controls have set TabStop=True and appropriate TabOrder's. However, pressing Tab in runtime when the form is shown does not do anything (it just produces a sound when a cursor/focus is in an Edit control and does nothing when a button is focused).
I have read in docs that Tab order would not work unless the Parent of the form is set. However, this is the only VCL form (the other windows are the console and the GLUT window), so there is no VCL parent AFAIK. I tried to set
Parent=Application->MainForm;
in the Form's constructor, but the Application->MainForm is also NULL. Any ideas?
Your problem is that you don't have a message loop. This is because console applications are not expected to have windows and do not come with message loops by default.
You can run a message loop by calling:
Application->Run();
However this will probably stop the console part of your application from working properly. How can your main thread service the console synchronously and the asynchronous GUI message loop at the same time?
I suspect you will need to have a more serious re-think of your application design.
Regarding your update, it seems that you do have a message loop, but it is the message loop for the GLUT framework. The VCL framework requires its message loop to handle dialog messages like TAB key presses.
It's plausible that running the VCL message loop in place of the GLUT message loop would give better results. But it's quite likely that would just break the GLUT part of the app.
Trying to run two incompatible GUI frameworks out of a single message loop is hard to get right. There's probably no quick fix here. You'll need to dig deeper. Perhaps it would be best to give up on the VCL and stick to the one GUI framework.

Selenium IDE simulate press ENTER for javascript configmation box

I am looking for allready for hours how to do this. So don't tell me to use search function. I know there are many things related.
There is many stuff on the internet and here, but no one works for me.
And I need a solution for Selenium IDE or something intergrated with it (if there is anything). Not RC and not WebDriver etc.
I need to simulate a key for an JavaScript confirmation popup, which has "OK" and "Cancel" buttons.
The problem is that I cannot select anything.
Popup appears when the site is opened. The Website itself is visible in the background, but no element can be selected (Firebug shows nothing as well, empty html(?)).
If I press ENTER key the confirmation box disappear (so it works fine manually).
This example seems good, but I can't find any interface in Selenium IDE to do this:
driver.switchTo().alert().accept();
(from Click in OK button inside an Alert (Selenium IDE))
I have only the following pattern:
Or write the test in html, which uses the "Command", "Target", "Value" pattern.
Appreciate any help.
EDIT1:
With the link provided by Janesh Kodikara
I have found that my problem is:
Selenium IDE will not be able to handle alerts that are within the page's onload() function. It will only be able to handle alerts that are generated after the page has completely loaded.
There is no "onload" function in my website, but the script part which creates the alert is inside html which is called with page (not in any function). This must be the same as "onload", because the alert comes immediately when the website is opened.
Once you have a confirmation box, you must consume it (Click OK or Cancel button)
You can use "chooseOkOnNextConfirmation" command to instruct Selenium IDE to simulate clicking OK button.
See http://www.guru99.com/enhancing-selenium-ide-script.html for more details.
You will not see the Javascript popup when IDE script is run.
Selenium IDE
Command : runScript
target : {window.onbeforeunload=function(e){};}
Command :click
target : xpath of button.
This will work fine but you are not able to see popup.

Resources