Could the notebook StyleSheet change the code behaviour? - wolfram-mathematica

I'd like to ask if someone had such a problem before. I have version 8.01, on windows 7, 64 bit. SP1.
I have been trying to find why I get Mathematica kernel crash when I added a Tooltip[] command to some code I am writing.
The notebook has the Wolfram Demonstration Style sheet (the Example style sheet which one uses to make demonstrations from). It is a Manipulate, all in one cell.
When I copy the code into a new notebook with default style sheet, the crash goes away! I can't reproduce the crash in the new notebook.
No code change at all. Just copied the whole cell and pasted it in a new notebook. Only difference is one has the Demonstration style sheet, and one is the default style sheet. When I change the stype sheet of the new notebook to Demostration, I notice the Tooltip does not work as well as before. When I use the Example notebook in this style, the minute I start moving the mouse with the toolstip, Kernel crashes.
To make sure, I did this few times. Same result. Once I add the Tooltip[], kernel crash right away only when the style sheet is demonstration.
My question: Has anyone seen such a behavior? I can make the two notebooks available if that is ok.
The crash I get is:
Problem signature:
Problem Event Name: BEX64
Application Name: Mathematica.exe
Application Version: 8.0.31.32201
Application Timestamp: 4d65e0e8
Fault Module Name: StackHash_2766
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Offset: 0000000000000001
Exception Code: c0000005
Exception Data: 0000000000000008
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 1033
Additional Information 1: 2766
Additional Information 2: 2766660d255034f6e73a8cd527b6f51e
Additional Information 3: 8ab7
Additional Information 4: 8ab74987ae95fade363a8e7256e3890f
I did send a bug report to WRI.
My question is: Has anyone had such a problem where a Style sheet change can make the code behave differently? Why would style sheet change cause such a problem?
Update 1:
I was able to make small example that shows part of the problem. I am working on making another small example that shows the crash itself. But this example below shows the problem, which is that Tooltip do not work the same when the style sheet is demonstration. First, here is a screen shot, side by side, same code, the left is in default style sheet, and the right is in Demonstration style
(below the image, I paste the source code, with steps how to reproduce the problem)
Manipulate[
EventHandler[Dynamic[Graphics[
{
Circle[{0,0},1],
Dynamic#Tooltip[Text[Style["O",Red,16] ,pt],Style[pt]]
},
ImageSize->250, PlotRange->{{-1,1},{-1,1}}
],ContinuousAction->True],
"MouseDragged":>
( pt=MousePosition["Graphics"] )
],
{{pt,{0,0}},ControlType->None},
TrackedSymbols:> {None},
ContinuousAction->True
]
steps:
Paste the above code in new style sheet, style default. Drag the point, you should see the coordinates display all the time, as you drag the point with the mouse.
File->New->Demonstration, and paste the same code in the Manipulate cell there replacing small template already there.
Now do the same, drag the point. You will see that the tooltip DO NOT display as the mouse is dragged. it only displays when holding the mouse steady over the point.
there is different behavior in dynamics that seems to cause this, or something else in this style.
I tried different style sheets, and the tooltip works ok there. only with Demonstration style sheet I get this problem with the tooltip.
If someone has a solution to this, it will be great. As I'd like to use tooltip in a demo.
I'll try to make an example that causes the crash also.
Update:
I've got back respsonce from WRI technical support. It is a Style sheet issue. Meanwhile, as a work around this is the suggestion From tech support:
I was able to reproduce the kernel crash. It looks like a demonstration
stylesheet issue related to imagesize fit.
At the top of the demonstration notebook there is tab called 'Tools',
clicking on it gives you an option called 'Resize Notebook to Fit'. On
resizing the notebook and saving it the kernel crash does not happen.
Thanks to WRI tech support.
update dec 2 2011
Based on John Fultz answer below, I am closing this question now. Thanks John.

(This answer is actually due to John Fultz -- see the comments under the original question. I'm turning it into an answer so that this question stops showing up on the unanswered-questions list. Clearly it's actually John who deserves any reputation points for this; John, if you post an answer here then I'll vote it up and delete mine.)
The reason why your tooltip isn't appearing in the demonstration version is that the Demonstration stylesheet puts a nonzero delay on tooltips, so that they only appear after hovering over them for a certain length of time. In particular, this means that they won't appear while dragging.
You can reverse this by setting the delay to zero on your Manipulate; do this by adding the following option to the Manipulate call.
BaseStyle -> {TooltipBoxOptions -> {TooltipDelay->0}}

Related

How to insert text into an Ace Editor instance as a comment

I am building a website where I want to allow people to code in almost any language that the Ace editor supports. Right now I have it redirect if they try to load a language that either isn't supported by Ace, or that I didn't list in my supported languages. I only have a few languages that I allow to run (because I haven't got others to work or don't know how to), and for all those other languages that aren't run-supported, I want to load the Ace editor with a note saying that the language they loaded isn't supported for running, but I want it to be a comment in that language.
I tried inserting the text using editor.setValue([message], -1). Then set the focus on the editor using editor.focus(). Then I select all the text with editor.selectAll(). And then use the editor.toggleCommentLines() to make it a comment. For some reason this doesn't work, and I am not sure why.
I know that I could just look up how to write comment in each of the languages that I am allowing, and then convert the message into a comment before inserting it into the editor, but I want an easier way if possible.
Is there an easier way to do it? Or should I just do what I said that I could?
Since I answered my own question, I want to ask another to see if anyone has the answer for this:
When in the Ace editor you can press CTRL+/ to toggle line comments. But if you press CTRL+SHIFT+/ it will toggle multiline comments. I don't see a function for this in the Ace editor documentation but because it works with a keyboard shortcut, there must be a way to do it programmatically, right?
If someone could figure this out, that would be great!
a user found it! See his comment to see the answer to this part.
I was trying a few more things, and one of them was doing a setTimeout on the editor.toggleCommentLines(), and that worked. The timeout worked best if I used 150ms or higher (I started with 2000 just to see if it worked at all, and then slowly moved down).
So the following code works to automatically insert a message and comment it out:
const editor = ace.edit([element]);
editor.setValue([message], 0); // You can also leave the second parameter blank, 0 is the default which automatically selects all.
setTimeout(() => {
editor.toggleCommentLines();
}, 150); // 150ms or more works best
You may also notice that this method clears out 2 methods that I was previously using. There are two reasons for this:
When using 0 instead of -1 for the second parameter of editor.setValue() it selects all the text.
Because we are using the editor variable, the editor doesn't need to be in "focus".

How does OpenEdge Progress-4GL work with ActiveX tabstrip component?

I would like to work with a tabstrip in my OpenEdge Progress-4GL environment, but I can't make it work.
"No problem: there's an example on the Progress website.", you might say, and indeed on this URL there's an example of a tabstrip (you might need to download the mentioned "TabStrip_sample.zip"), where a Listview is placed on one of the tabs and a Treeview on the other tab. (Don't be afraid: the zipfile only contains source code, bitmaps and an automatically created *.wrx file, which won't harm your computer)
Now the question: how on Earth did they do it?
Into the file "dbtest.w" let's have a look at both tabs at design time (after having resized the Listview):
It is clear that all components are put on the TabStrip component, so the linking between the tabs and the components should be done at runtime (just as mentioned in the URL), but here's the catch:
There seems not to be any event handler ON ... CFTabStrip or anything in the code.
The keys ("Db_tbl" and "Db_sch") NOR the indexes (1 and 2) of the individual tab pages, mentioned in CFTabStrip's property editor, are nowhere to be seen in the code.
Can anyone explain me how they did it?
Thanks in advance
The "magic" is in PROCEDURE CFTabStrip.TabStrip.MouseDown, which checks if the horizontal location (x) would have meant the first tab or the right tab and then hides / shows one or the other.
Pretty clunky, but if you look at the header, this example was created nearly twenty years ago to work with Progress 8.

How to quickly snap a view in storyboard back into its constraints after accidentally moving it

Everything I have found, every one says this cant be done.
I studied in fullsail university and they taught me how to do this so I know without a doubt it can be done. No one just knows how and assumes it can't.
Basically, when in XCode-story board, I would add constraints to a view and everything is all blue and perfect. From there, if you click, hold a drag, the view to another position then all of the constraints will turn orange. (Not RED because the constraints are still good it just simply needs to snap back into place..)
When in school my teacher taught me a quick key short cut that you press and everything snaps back into place and its all blue again. It has been a while since I have coded and i am just now getting back into it again and i just cant remember what that shortcut was.
I hope someone out there knows how to do this. Maybe any fullsail graduates?
Your responses are greatly appreciated.
I figured it out.
option + CMND + '='
What you're looking to do is referred to as "Update(ing) Frames."
The quick command is indeed option-command-equals
The command can also be reached from the bottom menu of a storyboard.
This link may change in the future but check out the Auto Layout Guide. Specifically reference the "Resolve Auto Layout Issues Tool" section.

ToolTip while Drop Down ComboBox

I have created a combo box in my project which takes a certain amount of numbers from a file.
This Combo drops down the list of the numbers each of represents something.
That something I want to be displayed in a tooltip when the mouse hovers on the combo box.
Until now everything has gone fine.
What I want now is to see the tooltip when the mouse rolls over the list of the dop down combo.
How can I do that? Until now the internet didn't give me something to work on it.
Is there some one to assist me on that?
Is this the sort of thing you're looking for, where a tooltip appears over a ComboBox item you mouse over?
If so take a look at this article on codeproject.com:
A Windows.Forms.ComboBox with Item ToolTips for 32 bit Windows XP (SP2)
It's VB.NET and currently displays a ComboBox item's text when moused over; I'm sure you can adapt it to your specific needs.
Finally I solved the issue with Combo Box which I mentioned on this question.
Of course there is no any solution give it from Microsoft for it, but with a small trick we manage to do what we want to do from one hand, and nobody seams to understand HOW we did it from the other hand.
So if anybody wants to see this solution please set a question and I will try to answer immediately.
For "bad and worst" please put a comment on this question.
My code is in vb.net.

VB6 silently deleting huge chunks of control data from forms

My project has maybe 130 controls (total of all labels, textboxes, etc.) in an SSTab (4 tabs). The project loads fine, it runs fine, I don't see a single error or warning at any point, but when I save the form with the SStab on it, the SStab data isn't saved (it is completely gone). Normally the relevant portion of the .frm file looks like this:
Begin TabDlg.SSTab SSTab1
Height = 8895
[1550 more lines of code for all the controls]
Width = 540
End
Begin VB.Menu FileMenu
But lately it's getting cropped to:
Begin TabDlg.SSTab SSTab1
Begin VB.Menu FileMenu
This is very frustrating! In my VB IDE, the frame, sstab, and all the controls are there, editable, running/compiling fine, no error messages at any point, but when you save the file, 1550 lines of precious sstab data just disappears - again, with no warning or error messages. So if you exit and restart the IDE, you get a form load error because 60% of the code is now missing. The log file points to the first error it finds (in this case a Begin TabDlg with no End) - there's no other info in it. (The log file was generated after the code was deleted and saved, so it makes sense that it wouldn't be helpful.)
When I first posted this question, I thought it had to do with the number of controls, because it appeared after I added a control, and in my first few tests, seemed to disappear when that control (or other controls) was deleted. Now I can't seem to get that form to save under any circumstances, even when I delete many controls (bringing the number of controls far below where it was when it was last stable).
I also tried deleting the SStab and moving all the controls to 4 different frames. I successfully did that in the IDE, but when I saved, a huge chunk of the data (starting with a slider control) was missing. So I have no fraking idea what is going on.
The problem is reproducible on two different PCs, so it doesn't appear to be a hardware/corrupt software VB install issue.
Has anyone else run into something like this?
Create a UserControl for each tab. That makes editing MUCH easier. It also allows you to nicely modularize the code, so each tab lives in its own file, and it'll allow you to reuse tabs elsewhere if you want.
Sounds horrible, never heard of anything like that.
Presumably you aren't getting an error log file from VB6 when you load the form into the IDE before it gets corrupted? The log file has the same filename as the form file but with a .log filename extension. For example, if errors occurred when loading Myform.frm, Visual Basic would create a log file named Myform.log. The error messages you might see there are documented in the manual.
Have a look in the Windows Event Log, see whether it records any interesting problems against the VB6 IDE?
Are you using any weird controls? Maybe one of them is somehow corrupting the FRM or FRX. FRM files are just text as you obviously know & the format is documented in the VB6 manual. Can you see any corruption in the FRM in a text editor? If you remove any properties defined in the FRX, does it still fail.
I think I would try creating a new project and a new form, and then use the IDE to copy and paste all the control definitions into it - no code. Play with the new form, see whether it has the same problem. Maybe you can recreate the form this way without the problem. If the new form does have the problem, do the same thing but only take half the controls. Maybe you can find a problem control by "binary search".
I get the same problem when attempting to save a form when the .FRM is writable but the .FRX is read-only
Not sure if this is the issue, but on a VB6 form, there is a limit to 255 (or is it 256) named controls. Perhaps you are running into that?
One way around that limitation is to use control arrays. For example, if you had 10 labels, instead of label1, label2, label3, etc, you could do label(0) through label(9), and use up only one named control.
The other thing worth mentioning about the SSTAB is the way it shows/hides controls. While it may appear that the controls are on separate tabs, what is really happening is that the controls are getting moved waaaayyyyy to the left (and consequently out of view). Perhaps with so many components, the SSTAB is choking on this in the IDE as it tries to render the controls in design view?
Again, not sure if this is the issue, but I know these two tidbits are relatively unknown.
So the SAVE function is not working.
I suspect one of the components you are placing on the tab strip is the culprit.
So ..
1) Take an inventory of each and every kind of component you are placing on the form
2) eliminate one (kind), SAVE
3) Did it SAVE?
-> Yes = that was the problematic control
-> No = return to step 2, but pick another kind
Of course, its important to remove all controls of a certain kind in step #2 (for example, ALL labels, or ALL textboxes, etc).
I have never heard of this happening however.
You are not alone! I've seen this problem. . .in fact I'm dealing it right now, which is what brought me to this site.
I've been working with VB since '94 (VB3) and I first saw this problem about 5 or 6 years ago, while using VB6. My solution then, was not unlike some of the suggestions that you have recieved from the good folks who've responded above: throw out the existing file and rebuild the form in a new file. I did that back and the affected form has worked ever since.
My current problem is appearing in another, much newer form, and the replace/rebuild option (performed about a month ago) only worked for about three weeks. Now the problem is back and each new iteration of the file gets corrupted very quickly. Following the reply above regarding the total number of allowable controls, I'm looking into just how many controls I have. . .and, as it happens, I was in the process of consolidating the primary the buttons and menus into control arrays, simply because it was going to streamline their management.
I can also confirm your observations about moving the project to a second PC. . . I've done that too, and problem persists. Moreover, I can add that I have moved the project from one shared storage system to another to no avail. (The original storage location was on a drive mounted to a Win-tel system and the new location is on a UNIX-based NAS!)
Just rebuilt the file again and checked: Controls.Count = 62, so I am no where near the 255 control limit mentioned previously. This is indeed strange! (Not to mention furstrating!)

Resources