In SDI application on right pain view on a FormView I am showing HTML preview using ChtmlView Navigate function. When I open doc/docx file in HTML preview then it was editable. I want to prevent click event so no one can edit this.
How can I stop click event on CHtmlView drived class ?
I try
BOOL CHtmlPreview::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONUP || pMsg->message == WM_LBUTTONDBLCLK)
{pMsg->message = 0;pMsg->wParam = 0; pMsg->lParam = 0;}
}
But when I click on previewed file (doc/docx ) in Chtmlview container then it is not handle by CHtmlPreview::PreTranslateMessage(MSG* pMsg) and not its parent CFormView drived class PreTranslateMessage(MSG* pMsg). Control not goes to these function.
My problem is like:
CHtmlView class and focus
I also try to overrides CHtmlView::OnTranslateAccelerator but this is not available in my CHtmlPreview class whose base class is ChtmlView.
Thanks
Related
Unity 5.4
Building a Unity WebGL application (not a game) that handles all 3D content on the Unity side of things, and all the UI is built using HTML/CSS/JS. By default, WebGLInput.captureAllKeyboardInput is set to true, which causes any input fields that require keyboard (text) input to be broken, as any keyboard controls are automatically being eaten up by Unity rather than going to the input field. Doing
#if !UNITY_EDITOR && UNITY_WEBGL
WebGLInput.captureAllKeyboardInput = false;
#endif
fixes the issue with input fields, but causes unity to ignore ALL keyboard inputs, even after the element is focused, however adding
tabindex="1"
to the fixes it so that keyboard input on HTML input fields works when focused, and keyboard controls inside the Unity WebGL app works when focused as well. (this is all per the docs: https://docs.unity3d.com/ScriptReference/WebGLInput-captureAllKeyboardInput.html). So that's all working fine.
However, the Unity WebGL application is still causing issues with some input fields using MOUSE (not keyboard) controls. Namely I've noticed it on input type="range" fields (HTML5 sliders) and input type="number (using keyboard to type in numbers works, but mouse clicking up and down do not).
Is there any sort of workaround to fix this? I essentially need to prevent the Unity WebGL canvas to not automatically take all mouse inputs, unless the element is clicked/focused first (just like the way the keyboard controls work). Anything to change on the Unity side to fix this? Or do I need to write some custom JavaScript to handle all input and determine whether it's intended for the Unity scene or the HTML UI?
I was having the same issue but I believe I've found a workaround! Originally I was just going to use OnApplicationFocus to toggle WebGLInput.captureAllKeyboardInput. But OnApplicationFocus doesn't work with WebGL builds of Unity so I'm doing this instead.
I have a script named "GameControl" on a GameObject also named "GameControl" in the first scene when the game is loaded.
// In the Start function of this script I call a function on the webpage to let it know that the game has loaded.
void Start () {
#if (UNITY_WEBPLAYER || UNITY_WEBGL) && !UNITY_EDITOR
try {
Application.ExternalCall("GameControlReady");
} catch (System.Exception e) {
Debug.LogError("GameControlReady function not on webpage"+e);
}
#endif
}
// This function will be called from the webpage
public void FocusCanvas (string p_focus) {
#if !UNITY_EDITOR && UNITY_WEBGL
if (p_focus == "0") {
WebGLInput.captureAllKeyboardInput = false;
} else {
WebGLInput.captureAllKeyboardInput = true;
}
#endif
}
On the webpage, I have the following javascript:
var gameReady = false;
// Called by Unity in GameControl's start function
function GameControlReady () {
gameReady = true;
}
function FocusCanvas(focus) {
if (gameReady) {
SendMessage("GameControl", "FocusCanvas", focus);
}
}
And in the head section of the webpage I have the following
<script type='text/javascript'>
document.addEventListener('click', function(e) {
if (e.target.id == "canvas") {
// Clicked on canvas
FocusCanvas("1");
} else {
// Clicked outside of canvas
FocusCanvas("0");
}
});
</script>
There is a button in opening component(welcome page) and it is invisible at the beginning. When user pass to another component, the button is supposed to be visible. However I cannot reach the property.
What is the way of importing opening component at (default package)?
this is the button:
<s:SWFLoader id="btnRepr" x="1790" y="1008.45" source="#Embed('Components/Starter/Assets/Buttons/ButtonReport.swf')" click="ShowReportPage" visible="false"/>
and this is the part I change visible to true:
btnRepr.visible = true;//Access of undefined property 'btnRepr'
Supposed that in your SWFComponent you have your SWFLoader :
<s:SWFLoader id="btnRepr" source="#Embed('ButtonReport.swf')" visible="false"/>
and you have another component called BTNComponent where you have a simple button which will show the SWF loaded in the SWFComponent's instance called swf_component, so you can do like this :
<s:Button click="button_clickHandler(event)"/>
and
protected function button_clickHandler(event:MouseEvent):void
{
mx.core.FlexGlobals.topLevelApplication.swf_component.btnRepr.visible = true;
}
Of course this is just a very simple and limited example if how you can do what you are looking for, you should improve it according to your specific needs ...
Edit :
Supposed that my two components are in MyComponents package, then to create their instances I did :
import MyComponents.*;
public var swf_component:SWFComponent;
public var btn_component:BTNComponent;
then inside the application's creation complete event handler, for example, I added :
swf_component = new SWFComponent();
addElement(swf_component);
btn_component = new BTNComponent();
addElement(btn_component);
then when the button inside the btn_component is clicked, the SWF inside the swf_component` is set visible.
Hope that can help.
I am working on a app using Adobe flash Builder which should pop up a Alert window once a particular event has been triggered.
Another event needs to be called when the Alert box is closed. But I do not see the Alert class in mx.controls library. It seems like the class (which existed in AS2) has been removed from AS3. Is there any other way to accomplish the same functionality?
Thanks,
Pritesh
Yo need to define closeHandler for your Alert control. Checkout the ActionScript 3.0 Reference api from here http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/Alert.html#show()
Use ExternalInterface.
import flash.external.ExternalInterface;
// tell flash what javascript function to listen for, and what flash function to call in response
ExternalInterace.addCallback('onAlertWindowClosed', onPopupClosed);
function openPopUp():void
{
// this conditional prevents errors when running local (yes, this needs uploaded to work)
if(ExternalInterface.available)
{
// this calls a javascript function in your html
ExternalInterface.call('myJavascriptAlertFuntion');
}
}
// this function is called from the javascript callback **onAlertWindowClosed**
function onPopupClosed():void
{
// do something when your popup closes
}
and in the html:
<script type="text/javscript>
// this chunk gets the flash object so you can call its methods
function getFlashMovieObject(movieName)
{
if (window.document[movieName])
{
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet") == -1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
else
{
return document.getElementById(movieName);
}
}
// function that is called from flash
function myJavascriptAlertFuntion()
{
alert("Hey! Yeah you there!");
}
// call this when you want to tell flash you are closing your popup
function tellFlashMyPopupWindowClosed()
{
// **flashContainer** should be replaced by the name parameter of your flash embed object
var flashMovie = getFlashMovieObject("flashContainer");
flashMovie.onAlertWindowClosed();
}
</script>
To have a popup alert in a Mobile project using MXML and AS3, you need to create a component based off of the SkinnablePopUpContainer from the Sparks components. (Since a simple alert has been conveniently uncluded.)
I learned alot reading up on the SkinnablePopUpContainer in the docs here:
The Spark SkinnablePopUpContainer container
To sum it up, I've created a component in MXML with SkinnablePopUpContainer as the base class. In the View that I want to have the popup to be added to, I create a new instance of the class in Actionscript. I listen to the custom events the buttons in the component will be firing on user response. To show the new popup component, simply call the static method open();. The open() method expects a parent container, and wether or not the popup should be Modal. Modal means that nothing under the component can receive user input.
var alert:SkinnablePopUpContainer = new SkinnablePopUpContainer;
alert.addEventListener( "OK", onOK );
alert.open( this, true );
function onOK(e:Event):void{ trace("User said OK") };
I'll put up some example files later when I can.
I am creating a menu this way :
myMenu = Menu.createMenu( null, myMenuXMLListCollection, false );
and then showing it with :
myMenu.popup( 10, 10 );
but the menu doesn't disappear automatically when i click somewhere outside the menu.
Is there some way to make the menu disappear automatically when i click outside it ?
Listen for the SandBoxMouseEvent.MOUSE_UP_SOMEWHERE on the sandbox root. You can get the Sandbox root using SystemManager.getSandboxRoot
So, add your event listener, something like this:
systemManager.getSandBoxRoot.addEventListener(SandboxMouseEvent.MOUSE_UP_SOMEWHERE, myMouseUpHandler);
And then in your event handler, just check to see if the target is the menu and if not hide the menu:
protected function myMouseUpHandler(event:SandboxMouseEvent):void{
if(event.target != myMenuInstance){
myMenuInstance.visible = false;
// or whatever other action you wish to take to hide the menu.
}
}
This is the general approach that the Flex ComboBox uses to hide the drop down menu on mouse click.
I am trying to put a button inside of an Openlayers popup. While the button appears to display correctly with the following code, the function 'handlerFunc' does not execute when the button is clicked. The segment of code I have posted is all within another function (so handlerFunc is actually a nested function). I'm using JQuery for the button itself. Any ideas on what might be going wrong? Thanks!
var feature = new OpenLayers.Feature(presences, ll);
feature.popupClass = popupClass;
feature.data.popupContentHTML = "<button id='popupButton'>Click me</button>";
feature.data.overflow = (overflow) ? "auto" : "hidden";
feature.data.icon = markerIcon;
$('#popupButton').button();
$('#popupButton').click(handlerFunc);
function handlerFunc() {
// do something
}
Most likely reason is that your button doesn't exist when you bind to a click event. $('#popupButton') returns null. Instead of using $('#popupButton').click(handlerFunc); try $('#popupButton').live('click', handlerFunc);. That means that we bind to an event not only when DOM is built, but when object appears.